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

status notification intent problem with music player ?

$
0
0

hi guys , i am building a music player app in android platform , i was stopped by a problem for many hours . i need to create a status bar notification to indicate that the music app is running (in background as well), i use the code below to create the notification , it worked , but when i clicked the notification , it took me back to the screen where my app just finished start up when the app has not started streaming the songs . here is my some lines of code : var Intent= Ti.Android.createIntent({ action : Ti.Android.ACTION_MAIN, className: 'className', packageName: 'package name', flags: Ti.Android.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP }); Intent.addCategory(Titanium.Android.CATEGORY_LAUNCHER); var pendingIntent = Ti.Android.createPendingIntent({ //activity: Ti.Android.currentActivity, activity:mainWin.activity, intent: Intent, type: Ti.Android.PENDING_INTENT_FOR_ACTIVITY, //flags: Ti.Android.FLAG_ACTIVITY_NO_HISTORY });

        var notification = Titanium.Android.createNotification({
            contentIntent: pendingIntent,
            contentTitle: 'MusicPlayer',
            contentText : 'is running...',
            tickerText: 'is running...',
            //defaults:Titanium.Android.NotificationManager.DEFAULT_SOUND,
            when: new Date(),
            icon : Ti.App.Android.R.drawable.appicon,
            flags : Titanium.Android.FLAG_SHOW_LIGHTS | Titanium.Android.FLAG_NO_CLEAR | Titanium.Android.FLAG_ONGOING_EVENT
        });
Ti.Android.NotificationManager.notify(1, notification);

what i want is , that the status notification will bring the user back to the app's current runing state , where they can see the current playing song name , duration , singer name . etc..

any advise will be appreciated ! thanks


Viewing all articles
Browse latest Browse all 8068

Trending Articles



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