1
我想建立一個通知,並顯示它,並建立一個堆棧,我所顯示的意圖。但我得到一個NameNotFoundException。NameNotFoundException在addParentStack
Intent resultIntent = new Intent(mContext, ForecastFragment.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
stackBuilder.addParentStack(ForecastFragment.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.
getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(10 ,mBuilder.build());
這是我得到的例外。
3541-3562/com.example.android.sunshine.app E/AndroidRuntime: FATAL EXCEPTION: SyncAdapterThread-1
Process: com.example.android.sunshine.app, PID: 3541
java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.example.android.sunshine.app/com.example.android.sunshine.app.ForecastFragment}
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:247)
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:226)
at com.example.android.sunshine.app.sync.SunshineSyncAdapter.notifyWeather(SunshineSyncAdapter.java:526)
at com.example.android.sunshine.app.sync.SunshineSyncAdapter.getWeatherDataFromJson(SunshineSyncAdapter.java:424)
at com.example.android.sunshine.app.sync.SunshineSyncAdapter.onPerformSync(SunshineSyncAdapter.java:255)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)
Caused by: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.example.android.sunshine.app/com.example.android.sunshine.app.ForecastFragment}
at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:314)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:301)
at android.support.v4.app.NavUtils.getParentActivityIntent(NavUtils.java:256)
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:240)
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:226)
at com.example.android.sunshine.app.sync.SunshineSyncAdapter.notifyWeather(SunshineSyncAdapter.java:526)
at com.example.android.sunshine.app.sync.SunshineSyncAdapter.getWeatherDataFromJson(SunshineSyncAdapter.java:424)
at com.example.android.sunshine.app.sync.SunshineSyncAdapter.onPerformSync(SunshineSyncAdapter.java:255)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)
我檢查了包名和類ForecastFragment
被放置在包裝,但它是正確的。 有人可以幫助我排序這一個。
謝謝你解決了我的問題。 –