jeudi 30 juin 2016

NameNotFoundException in addParentStack

I am trying to build a notification and display it and also build a stack to the intent which I am displaying. But i get a NameNotFoundException.

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());

Here is the exception that I get.

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)

I checked the Package name and the package where the class ForecastFragment is placed but it is all correct. Can someone please help me out in sorting this one.

Aucun commentaire:

Enregistrer un commentaire