Android 悬挂式帐篷不起作用
我有一个将显示通知的服务。通知显示正确,但当我单击NoFifification时,什么也没有发生。它应该在我的应用程序中打开一个活动。这是我的密码:Android 悬挂式帐篷不起作用,android,android-pendingintent,Android,Android Pendingintent,我有一个将显示通知的服务。通知显示正确,但当我单击NoFifification时,什么也没有发生。它应该在我的应用程序中打开一个活动。这是我的密码: public class ServiceCheckExpensesRecurring extends Service{ @Override public int onStartCommand(Intent intent, int flags, int startId) { int mNoti
public class ServiceCheckExpensesRecurring extends Service{
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
int mNotificationId = 001;
Intent myIntent = new Intent(this, MenuDashboard.class);
myIntent.setAction(Intent.ACTION_VIEW);
myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pIntent = PendingIntent.getActivity(getBaseContext(), 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder n = new NotificationCompat.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject")
.setSmallIcon(R.drawable.common_signin_btn_icon_light)
.setContentIntent(pIntent)
.setAutoCancel(true);
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(mNotificationId, n.build());
return Service.START_NOT_STICKY;
}
}
仅供参考,MenuDashboard是一个片段(如果有帮助的话)。我正在使用我的索尼experia mini和ICS,它可以启动活动(或服务),但不能启动碎片
如果MenuDashboard
是一个片段,那么它将无法工作
您应该改为使用活动,并将片段嵌入其中。尝试了此操作,但仍然没有成功。我从来不知道。android至少应该抛出一个错误。所以无法从通知中加载片段?ermm如何在活动中嵌入片段?我之所以需要启动这个片段,是因为我的应用程序使用了导航抽屉,而且菜单中的所有活动都是fragment@imin在这种情况下,您可以将意图重新传递到您的活动(具有抽屉的活动),然后实现
onNewIntent()
。酷。。。我第一次听说onNewIntent()。但我只是在谷歌上搜索了“onNewIntent call fragment”,我不认为我找到了任何有助于我从活动中调用片段的结果。你能给我指出正确的方向吗?@imin你应该能够在添加片段的地方包含相同的代码。