Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

show notification in onather window

$
0
0

Hi i have successfully made a local notification now i want when i clik in the notification i want it tobe shawn in onther window how can i do that
this my code: app.js

var win = Ti.UI.createWindow({
    backgroundColor : '#ccc',
    title : 'Android Cloud Push Notification'
});
var btn=Titanium.UI.createButton({
 
    top:30
});
 
 
var activity = Ti.Android.currentActivity;
 var intent = Ti.Android.createIntent({
        action : Ti.Android.ACTION_MAIN,
        // you can use className or url to launch the app
        // className and packageName can be found by looking in the build folder
        // for example, mine looked like this
        // build/android/gen/com/appcelerator/test/Test7Activity.java
        // className : 'com.appcelerator.test.Test7Activity',
 
        // if you use url, you need to make some changes to your tiapp.xml
        url : 'info.js',
        flags : Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP
    });
    intent.addCategory(Titanium.Android.CATEGORY_LAUNCHER);
 
    var pending = Ti.Android.createPendingIntent({
        activity : activity,
        intent : intent,
        type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
        flags : Ti.Android.FLAG_ACTIVITY_NO_HISTORY
    });
var xhrr=Titanium.Network.createHTTPClient();
 
xhrr.onload=function()
{
 
    var json=JSON.parse(this.responseText);
 
    var jsonn=json.updatesResult;
    //alert(json);
    for(var i=0;i++;i<json.length)
    {
 
        Ti.App.Properties.setString('name',jsonn[i].getEventName);
 
        Ti.App.Properties.setString('date',jsonn[i].getEventDate);
    }
    Ti.App.Properties.setList('names',jsonn);
};
xhrr.onerror=function(){
 
    alert('error network');
};
var data=Ti.App.Properties.getList('names');
 
//var x =Ti.App.Properties.getString('name');
var xx=Ti.App.Properties.getString('date');
 
 
 
 
    var notification = Ti.Android.createNotification({
        contentIntent : pending,
        contentTitle : 'Famissima Sorties',
        contentText :"cher client la date d évenement \t" +data[0].getEventName+"est à apporter vers"+xx,
        tickerText : 'Evénement'+data[0].getEventName,
        // "when" will only put the timestamp on the notification and nothing else.
        // Setting it does not show the notification in the future
        when : new Date().getTime(),
        icon : Ti.App.Android.R.drawable.appicon,
        repeat:'daily',
         defaults:Titanium.Android.NotificationManager.DEFAULT_SOUND,
        flags : Titanium.Android.ACTION_DEFAULT | Titanium.Android.FLAG_AUTO_CANCEL | Titanium.Android.FLAG_SHOW_LIGHTS
    });
 
    Ti.Android.NotificationManager.notify(1, notification);  
 
 
  btn.addEventListener('click',function()
 
{
    alert(data[0].getEventName +data.length);
 
});
xhrr.open('GET','http://XXXXXXXX/Mobile.svc/updates');
//xhrr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
xhrr.send();
 
 
 
/*var win = Titanium.UI.createWindow({
    backgroundColor : 'blue'
});
var btn = Ti.UI.createButton({
    title : 'Add Notification'
});
 
btn.addEventListener('click', function(e) {
    var now = new Date().getTime();
    var delta = new Date( now + (4 * 1000) );
    var deltaMS = delta - now;
 
    var intent = Ti.Android.createServiceIntent({
        url : 'ExampleService.js'
    });
    intent.putExtra('interval', deltaMS);
    intent.putExtra('message' , 'This is that little extra');
    Ti.Android.startService(intent);
}); */
win.add(btn);
win.open();
and this info.js
var win =Titanium.UI.createWindow({
 
    backgroundColor:"yellow"
});
 
 
var label =Titanium.UI.createLabel({
 
    text:'hello'
 
});
win.add(label);
win.open();
and here tiapp.xml
<android xmlns:android="http://schemas.android.com/apk/res/android">
     <manifest>
 
        <uses-permission android:name="android.permission.VIBRATE"/>
     </manifest> 
 
   <!-- the activities tag must be added if you want to use the url property to launch your app -->
   <activities>
 
        <activity url="info.js">
           <intent-filter>
               <action android:name="android.intent.action.VIEW"/>
               <category android:name="android.intent.category.DEFAULT"/>
               <category android:name="android.intent.category.BROWSABLE"/>
           </intent-filter>
 
       </activity>
   </activities>
 
</android>
any help plz i will be much thnkful

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>