Unable to use GetIntExtra integer value in for calculation - android

MainClass.java
Intent i;
i = new Intent(v.getContext(), Next.class);
i.putExtra("increment1",1);
v.getContext().startActivity(i);
Next.java
Intent mIntent = getIntent();
int age=mIntent.getIntExtra("increment1", 0);
String age1=Integer.toString(age);
Toast.makeText(this,age1, Toast.LENGTH_LONG).show();
When I use variable age in my toast I'm getting below error. That means, I can't use Integer value. Please help me to use the Integer value.
java.lang.RuntimeException: Unable to start activity ComponentInfo{test.myapplication/test.myapplication.Next}: android.content.res.Resources$NotFoundException: String resource ID #0x2
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1572)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5896)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2
at android.content.res.Resources.getText(Resources.java:380)
at android.widget.TextView.setText(TextView.java:4564)
at test.myapplication.Next.onCreate(Next.java:28)
at android.app.Activity.performCreate(Activity.java:6298)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2608)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1572) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:207) 
at android.app.ActivityThread.main(ActivityThread.java:5896) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 

Related

Android Studio Getting Error While onClick

public void Clicking(View view) {
double one = Double.parseDouble(testtt.getText().toString());
double two = Double.parseDouble(tessss.getText().toString());
}
already;
testtt [TextView] = "0.0001974794"
tessss [TextView] = "0"
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.Testing_Appi, PID: 2988
java.lang.IllegalStateException: Could not execute method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:402)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22265)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:397)
at android.view.View.performClick(View.java:5610) 
at android.view.View$PerformClick.run(View.java:22265) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 
Caused by: java.lang.NumberFormatException: For input string: "0.0001974794"
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1306)
at java.lang.Double.parseDouble(Double.java:547)
at com.example.Testing_Appi.MainActivity.testor(MainActivity.java:153)
at java.lang.reflect.Method.invoke(Native Method) 
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:397) 
at android.view.View.performClick(View.java:5610) 
at android.view.View$PerformClick.run(View.java:22265) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 
I couldn't spot where the error was!
Example : Find your view by id with view
EditText testttET = view.findViewById(R.id.testtt);
String text = testttET.getText().toString();
check if your text is not empty
if(!text.equals("")){
double value = Double.parseDouble(text);
}

How does the Intent with Parcelable pass between two App?

I have got Service in android app2. I want to start Service from app1 and pass Album object in Intent to Service in app2.
In app1
var alb: Album = Album()
alb.name="album name"
alb.numOfSongs=1
alb.thumbnail=2
var serviceIntent: Intent = Intent();
var componentName: ComponentName = ComponentName("com.eusecom.demoad","com.eusecom.demoad.view.EkasaService")
serviceIntent.setComponent(componentName)
serviceIntent.putExtra("albumpar", alb)
context.startService(serviceIntent)
In app2 in Service class
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
Album alb = intent.getParcelableExtra("albumpar");
}
I can to pass String in Intent. If i put to Intent the Parcelable i get error.
02-27 14:12:18.438 22198-22198/com.eusecom.demoad E/Parcel: Class not found when unmarshalling: com.eusecom.samshopersung.models.Album
java.lang.ClassNotFoundException: com.eusecom.samshopersung.models.Album
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at android.os.Parcel.readParcelableCreator(Parcel.java:2517)
at android.os.Parcel.readParcelable(Parcel.java:2471)
at android.os.Parcel.readValue(Parcel.java:2374)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2727)
at android.os.BaseBundle.unparcel(BaseBundle.java:269)
at android.os.BaseBundle.getString(BaseBundle.java:992)
at android.content.Intent.getStringExtra(Intent.java:6743)
at com.eusecom.demoad.view.EkasaService.onStartCommand(EkasaService.java:29)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3685)
at android.app.ActivityThread.-wrap23(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1740)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.eusecom.samshopersung.models.Album" on path: DexPathList[[zip file "/data/app/com.eusecom.demoad-1/base.apk"],nativeLibraryDirectories=[/data/app/com.eusecom.demoad-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:400) 
at android.os.Parcel.readParcelableCreator(Parcel.java:2517) 
at android.os.Parcel.readParcelable(Parcel.java:2471) 
at android.os.Parcel.readValue(Parcel.java:2374) 
at android.os.Parcel.readArrayMapInternal(Parcel.java:2727) 
at android.os.BaseBundle.unparcel(BaseBundle.java:269) 
at android.os.BaseBundle.getString(BaseBundle.java:992) 
at android.content.Intent.getStringExtra(Intent.java:6743) 
at com.eusecom.demoad.view.EkasaService.onStartCommand(EkasaService.java:29) 
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3685) 
at android.app.ActivityThread.-wrap23(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1740) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6692) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) 
02-27 14:12:18.439 22198-22198/com.eusecom.demoad D/AndroidRuntime: Shutting down VM
02-27 14:12:18.440 22198-22198/com.eusecom.demoad E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.eusecom.demoad, PID: 22198
java.lang.RuntimeException: Unable to start service com.eusecom.demoad.view.EkasaService#fe9af21 with Intent { cmp=com.eusecom.demoad/.view.EkasaService launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } (has extras) }: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.eusecom.samshopersung.models.Album
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3702)
at android.app.ActivityThread.-wrap23(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1740)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.eusecom.samshopersung.models.Album
at android.os.Parcel.readParcelableCreator(Parcel.java:2545)
at android.os.Parcel.readParcelable(Parcel.java:2471)
at android.os.Parcel.readValue(Parcel.java:2374)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2727)
at android.os.BaseBundle.unparcel(BaseBundle.java:269)
at android.os.BaseBundle.getString(BaseBundle.java:992)
at android.content.Intent.getStringExtra(Intent.java:6743)
at com.eusecom.demoad.view.EkasaService.onStartCommand(EkasaService.java:29)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3685)
at android.app.ActivityThread.-wrap23(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1740) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6692) 
at java.lang.reflect.Method.invoke(Native Method) 
You are better off serializing the object to a String, passing the String in the Intent and then deserialize the String to an object in the target application.

Why cannot convert from string to int?

It should be something easy to do, but these commands return error when I try to convert a String to integer:
Intent recibir = getIntent();
String nombre = recibir.getStringExtra("hora_inicio");
int numero=0;
try {
numero = Integer.parseInt(nombre);
} catch(NumberFormatException nfe) {
nfe.printStackTrace();
}
Toast.makeText(this, numero, Toast.LENGTH_SHORT).show();
Android monitor returns this error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.cristobal.policlinica, PID: 11025
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.cristobal.policlinica/com.example.cristobal.policlinica.CalendarActivity}:
android.content.res.Resources$NotFoundException: String resource ID
0x9
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.content.res.Resources$NotFoundException: String
resource 0x9
at android.content.res.Resources.getText(Resources.java:312)
at android.widget.Toast.makeText(Toast.java:286)
at
com.example.cristobal.policlinica.CalendarActivity.onCreate(CalendarActivity.java:31)
at android.app.Activity.performCreate(Activity.java:6237)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
thanks in advance
The problem is not with your conversion but with your Toast.makeText. When you call Toast.makeText(this, numero, Toast.LENGTH_SHORT).show();
It considers numero as resId and tries to find the relative string resource in strings.xml which fails giving error:
Resources$NotFoundException: String resource ID
Instead of
Toast.makeText(this, numero, Toast.LENGTH_SHORT).show();
DO
Toast.makeText(this, String.valueOf(numero), Toast.LENGTH_SHORT).show();
Try this:
number = Integer.parseInt(YourStringName.toString());
Toast.makeText(this, String.valueOf(numero), Toast.LENGTH_SHORT).show();

Could Not Pass LatLng object from fragment to activity

I am trying to pass Location object to another activity from the fragment but I am getting these errors.
FATAL EXCEPTION: main
Process: com.shaby.lifeline, PID: 24143
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.shaby.lifeline.pojo.SearchListProvider)
at android.os.Parcel.writeSerializable(Parcel.java:1388)
at android.os.Parcel.writeValue(Parcel.java:1335)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:638)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
at android.os.Bundle.writeToParcel(Bundle.java:1096)
at android.os.Parcel.writeBundle(Parcel.java:663)
at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:148)
at android.os.Parcel.writeTypedArray(Parcel.java:1191)
at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:564)
at android.os.Parcel.writeParcelable(Parcel.java:1357)
at android.os.Parcel.writeValue(Parcel.java:1262)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:638)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
at android.os.Bundle.writeToParcel(Bundle.java:1096)
at android.os.Parcel.writeBundle(Parcel.java:663)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2969)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3450)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5529)
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:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
Caused by: java.io.NotSerializableException: com.google.android.gms.maps.model.LatLng
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
at android.os.Parcel.writeSerializable(Parcel.java:1383)
at android.os.Parcel.writeValue(Parcel.java:1335) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:638) 
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313) 
at android.os.Bundle.writeToParcel(Bundle.java:1096) 
at android.os.Parcel.writeBundle(Parcel.java:663) 
at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:148) 
at android.os.Parcel.writeTypedArray(Parcel.java:1191) 
at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:564) 
at android.os.Parcel.writeParcelable(Parcel.java:1357) 
at android.os.Parcel.writeValue(Parcel.java:1262) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:638) 
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313) 
at android.os.Bundle.writeToParcel(Bundle.java:1096) 
at android.os.Parcel.writeBundle(Parcel.java:663) 
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2969) 
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3450) 
at android.os.Handler.handleCallback(Handler.java:810) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:189) 
at android.app.ActivityThread.main(ActivityThread.java:5529) 
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:950) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745) 
I tried it passing as a bundle in form of parceable object but still same error. I tried just activity change then it was fine.
This is code when I pass the location as parcel.
Intent intent= new Intent(getActivity(), ConfirmBookingActivity.class);
Bundle b= new Bundle();
b.putParcelable("source_marker", sourceMarker.getPosition());
b.putParcelable("destination_marker", destinationMarker.getPosition());
intent.putExtras(b);
startActivity(intent);
Also when I tried to pass location as string then also same exception persists, I dont know why??

NotSerializableException: android.graphics.drawable.BitmapDrawable

I get the following error, I know this means that Some class has to be implements Serializable but the problem is all the classes I've created does implement Serializable.
Process: com.example.awarrior.gallery, PID: 2554
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.example.awarrior.gallery.Item)
at android.os.Parcel.writeSerializable(Parcel.java:1526)
at android.os.Parcel.writeValue(Parcel.java:1474)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:723)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
at android.os.Bundle.writeToParcel(Bundle.java:1133)
at android.os.Parcel.writeBundle(Parcel.java:763)
at android.content.Intent.writeToParcel(Intent.java:8655)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3052)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1518)
at android.app.ContextImpl.startActivity(ContextImpl.java:819)
at android.app.ContextImpl.startActivity(ContextImpl.java:796)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)
at com.example.awarrior.gallery.ItemAdapter$1.onClick(ItemAdapter.java:57)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22265)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.io.NotSerializableException: android.graphics.drawable.BitmapDrawable
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1224)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1584)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1549)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1472)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1218)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at android.os.Parcel.writeSerializable(Parcel.java:1521)
at android.os.Parcel.writeValue(Parcel.java:1474) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:723) 
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408) 
at android.os.Bundle.writeToParcel(Bundle.java:1133) 
at android.os.Parcel.writeBundle(Parcel.java:763) 
at android.content.Intent.writeToParcel(Intent.java:8655) 
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3052) 
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1518) 
at android.app.ContextImpl.startActivity(ContextImpl.java:819) 
at android.app.ContextImpl.startActivity(ContextImpl.java:796) 
at android.content.ContextWrapper.startActivity(ContextWrapper.java:356) 
at com.example.awarrior.gallery.ItemAdapter$1.onClick(ItemAdapter.java:57) 
at android.view.View.performClick(View.java:5610) 
at android.view.View$PerformClick.run(View.java:22265) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method)
here's the code that causes the error.
holder.ivImg.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v) {
Intent intent = new Intent(context, Detail.class);
intent.putExtra("item", item);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
});
The problem was that you can't serialize Bitmaps so instead you may serialize its URL, but I'm not sure what to do if the image was in drawble folder.

Categories

Resources