I'm trying to send data between activities, this is the sending code:
public void sendToFavorites(Context context){
String vID,vThumbnail,vTitle;
Bundle extras = new Bundle();
vID = sendResult.getId().getVideoId();
vThumbnail = sendResult.getSnippet().getThumbnails().getMedium().getUrl();
vTitle = sendResult.getSnippet().getTitle();
extras.putString("id",vID);
intent = new Intent(context,Favorites.class);
intent.putExtras(extras);
startActivity(intent); <----- Application crash here.
}
This is the logcat:
05-18 18:39:00.560 28528-28528/project.youtubeplayer E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: project.youtubeplayer, PID: 28528
java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
at android.app.Activity.startActivityForResult(Activity.java:3745)
at android.app.Activity.startActivityForResult(Activity.java:3706)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
at android.app.Activity.startActivity(Activity.java:4016)
at android.app.Activity.startActivity(Activity.java:3984)
at project.youtubeplayer.MainActivity.sendToFavorites(MainActivity.java:183)
at project.youtubeplayer.YtAdapter$1.onClick(YtAdapter.java:77)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Calling to sendToFavroites:
mHolder.mVideoFavorite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AppUtils.showToast(result.getSnippet().getTitle() + " Was added to favorites.");
m.sendResult = result;
m.sendToFavorites(mActivity);
}
});
I tried to search the net for that problem but couldn't find any answers..
Aucun commentaire:
Enregistrer un commentaire