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

how to open a specific window on notification click in titanium android

$
0
0

hi everyone,

i am developing a mobile app for android OS using titanium sdk version 3.1.1.GA and i am struggling to get it worked. what i want to do is open a specific window when i click on the notification. i am able to show a notification but when i click on it it shows the last window from the activity stack.

my code to create notification from logservice.js

var intent = Ti.Android.createIntent({
                    action : Ti.Android.ACTION_MAIN,
                    // className : '<application id>.NotifierActivity',
                   url : 'alertmsg.js',
                    flags : Ti.Android.FLAG_ACTIVITY_NEW_TASK | Ti.Android.FLAG_ACTIVITY_CLEAR_TOP
                });
                intent.addCategory(Titanium.Android.CATEGORY_LAUNCHER);
 
            // Create a PendingIntent to tie together the Activity and Intent
            var pending = Titanium.Android.createPendingIntent({
                intent: intent,
                flags: Titanium.Android.FLAG_UPDATE_CURRENT
            });
 
            // Create the notification
            var notification = Titanium.Android.createNotification({
                // icon is passed as an Android resource ID -- see Ti.App.Android.R.
                //icon: Ti.App.Android.R.drawable.my_icon,
                contentTitle: 'Reminder pending',
                contentText : 'Click to return to the application.',
                contentIntent: pending,
                //sound: 'click.mp3',
                defaults: Titanium.Android.NotificationManager.DEFAULT_ALL,
            });
            // Send the notification.
            Titanium.Android.NotificationManager.notify(1, notification);
code from my TiApp.xml file
<android xmlns:android="http://schemas.android.com/apk/res/android">
   <services>
    <service type="interval" url="logservice.js"/>
  </services>
   <manifest>
  <uses-permission android:name="android.permission.VIBRATE" ></uses-permission>
   </manifest>
   <application>
     <activities>
       <activity url="alertmsg.js">
           <intent-filter>
              <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
               <category android:name="android.intent.category.BROWSABLE"/>
           </intent-filter>
       </activity>
   </activities>
   </application>
 </android>
any help?? Thanks in advance.

Viewing all articles
Browse latest Browse all 8068

Latest Images

Trending Articles



Latest Images