【发布时间】:2016-05-03 16:01:43
【问题描述】:
我是安卓开发的新手。我有播放一个音频的应用程序。当我运行我的应用程序时,然后播放该音频。我想在转到另一个应用程序(后退按钮/主页)时播放音频。我也有一个通知栏。当我单击该通知栏时。然后将运行正在播放音频的活动。但不会再次启动该音频(在音频播放之前保留)。有可能的。
我的代码如下:
Notification.Builder mBuilder =
new Notification.Builder(this)
.setSmallIcon(R.drawable.cmplayer)
.setContentTitle("CoderoMusicPlayer")
.setContentText("PLayer0!");
Intent resultIntent = new Intent(this,
AndroidBuildingMusicPlayerActivity.class);
resultIntent.setAction(Intent.ACTION_MAIN);
resultIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
resultIntent, 0);
mBuilder.setContentIntent(pendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
[完整代码]
最后,我想一次运行音频一直运行一次。我要么继续使用应用程序,要么退出应用程序。
解决此问题的任何建议或想法或解决方案。谢谢
【问题讨论】:
-
你能把你开始播放音频和其他相关方法的代码贴出来吗?
-
我在 onCreate() 方法中编写代码。 @ljpv14
标签: eclipse android-intent android-notifications