I want to send data from one activity to another activity using intent as shown when i try that i get an array as below.While sending data it shows error as below.It adds array on one side but doesn't send data to other side.While receiving on other side it gives error.Thank you in advance.
package com.example.testing1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import java.util.ArrayList;
public class Testing2 extends AppCompatActivity {
ArrayList<String> hisnumber=null;
ArrayList<Bitmap> hisimages=null;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testing2);
hisnumber=new ArrayList<>();
hisimages=new ArrayList<>();
button=findViewById(R.id.button);
Intent intent = getIntent();
hisnumber = intent.getStringArrayListExtra("hisnumber");
hisimages = intent.getParcelableArrayListExtra("hisimages");
Log.d("num3", String.valueOf(hisnumber));
Log.d("img3", String.valueOf(hisimages));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(hisnumber==null){
hisnumber=new ArrayList<>();
hisimages=new ArrayList<>();
}
hisnumber.add("ass");
Bitmap bp= BitmapFactory.decodeResource(getResources(), R.drawable.defaults);
hisimages.add(bp);
if (hisimages != null) {
Log.d("checks", String.valueOf(hisnumber));
Log.d("checks", String.valueOf(hisimages));
}
Intent myIntent = new Intent(Testing2.this, MainActivity.class);
myIntent.putExtra("hisnumber", hisnumber);
myIntent.putParcelableArrayListExtra("hisimages", hisimages);
Log.d("num2", String.valueOf(hisnumber));
Log.d("img2", String.valueOf(hisimages));
startActivity(myIntent);
}
});
}
}
Testing2.java
package com.example.testing1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
ArrayList<String> hisnumber=null;
ArrayList<Bitmap> hisimages=null;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=findViewById(R.id.button);
Intent intent = getIntent();
hisnumber=new ArrayList<>();
hisimages=new ArrayList<>();
hisnumber = intent.getStringArrayListExtra("hisnumber");
hisimages = intent.getParcelableArrayListExtra("hisimages");
Log.d("num1", String.valueOf(hisnumber));
Log.d("img1", String.valueOf(hisimages));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent myIntent = new Intent(MainActivity.this, Testing2.class);
myIntent.putExtra("hisnumber", hisnumber);
myIntent.putParcelableArrayListExtra("hisimages", hisimages);
Log.d("num", String.valueOf(hisnumber));
Log.d("img", String.valueOf(hisimages));
startActivity(myIntent);
}
});
}
}
MainActivity.java
07/28 15:17:36: Launching 'app' on Realme RMX1901.
$ adb shell am start -n "com.example.testing1/com.example.testing1.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 889 on device 'realme-rmx1901-618cb732'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/xample.testing: Late-enabling -Xcheck:jni
E/xample.testing: Unknown bits set in runtime_flags: 0x28000
I/Perf: Connecting to perf service.
E/Perf: Fail to get file list com.example.testing1
E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
Fail to get file list com.example.testing1
getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
Fail to get file list oat
getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
W/xample.testing: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/xample.testing: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/num1: null
D/img1: null
D/WindowManager: Add to mViews: DecorView@5a6d981[MainActivity], this = android.view.WindowManagerGlobal@9161a26,pkg= com.example.testing1
I/AdrenoGLES: QUALCOMM build : e4029f9, I6b4cbc7431
Build Date : 10/01/19
OpenGL ES Shader Compiler Version: EV031.27.05.01
Local Branch :
Remote Branch :
Remote Branch :
Reconstruct Branch :
Build Config : S P 8.0.11 AArch64
I/AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
W/AdrenoUtils: <ReadGpuID_from_sysfs:194>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
<ReadGpuID:218>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
W/Gralloc3: mapper 3.x is not supported
I/Choreographer: Skipped 3 frames! The application may be doing too much work on its main thread.
D/ColorViewRootUtil: nav gesture mode swipeFromBottom ignore false downY 358 mScreenHeight 2340 mScreenWidth 1080 mStatusBarHeight 54 globalScale 1.125 nav mode 3 event MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=402.0, y[0]=358.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=675149637, downTime=675149637, deviceId=7, source=0x1002, displayId=0 } rotation 0
D/num: null
D/img: null
I/Choreographer: Skipped 1 frames! The application may be doing too much work on its main thread.
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@fa02c62
D/num3: null
D/img3: null
D/WindowManager: Add to mViews: DecorView@b9c1a0e[Testing2], this = android.view.WindowManagerGlobal@9161a26,pkg= com.example.testing1
I/Choreographer: Skipped 3 frames! The application may be doing too much work on its main thread.
I/Choreographer: Skipped 1 frames! The application may be doing too much work on its main thread.
D/ColorViewRootUtil: nav gesture mode swipeFromBottom ignore false downY 351 mScreenHeight 2340 mScreenWidth 1080 mStatusBarHeight 54 globalScale 1.125 nav mode 3 event MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=200.0, y[0]=351.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=675153043, downTime=675153043, deviceId=7, source=0x1002, displayId=0 } rotation 0
I/Choreographer: Skipped 5 frames! The application may be doing too much work on its main thread.
D/checks: [ass]
[android.graphics.Bitmap@47d8cd4]
D/num2: [ass]
D/img2: [android.graphics.Bitmap@47d8cd4]
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 3240640)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.testing1, PID: 889
java.lang.RuntimeException: Failure from system
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1720)
at android.app.Activity.startActivityForResult(Activity.java:5319)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
at android.app.Activity.startActivityForResult(Activity.java:5263)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
at android.app.Activity.startActivity(Activity.java:5648)
at android.app.Activity.startActivity(Activity.java:5616)
at com.example.testing1.Testing2$1.onClick(Testing2.java:50)
at android.view.View.performClick(View.java:7256)
at android.view.View.performClickInternal(View.java:7218)
at android.view.View.access$3800(View.java:824)
at android.view.View$PerformClick.run(View.java:27719)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:228)
at android.app.ActivityThread.main(ActivityThread.java:7782)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
Caused by: android.os.TransactionTooLargeException: data parcel size 3240640 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:523)
at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:3868)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1714)
at android.app.Activity.startActivityForResult(Activity.java:5319)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
at android.app.Activity.startActivityForResult(Activity.java:5263)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
at android.app.Activity.startActivity(Activity.java:5648)
at android.app.Activity.startActivity(Activity.java:5616)
at com.example.testing1.Testing2$1.onClick(Testing2.java:50)
at android.view.View.performClick(View.java:7256)
at android.view.View.performClickInternal(View.java:7218)
at android.view.View.access$3800(View.java:824)
at android.view.View$PerformClick.run(View.java:27719)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:228)
at android.app.ActivityThread.main(ActivityThread.java:7782)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
I/Process: Sending signal. PID: 889 SIG: 9
Connected to process 1064 on device 'realme-rmx1901-618cb732'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/Perf: Connecting to perf service.
E/Perf: Fail to get file list com.example.testing1
E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
Fail to get file list com.example.testing1
getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
Fail to get file list oat
getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
W/xample.testing: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/xample.testing: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/num1: null
D/img1: null
D/WindowManager: Add to mViews: DecorView@9161a26[MainActivity], this = android.view.WindowManagerGlobal@9c4e667,pkg= com.example.testing1
I/AdrenoGLES: QUALCOMM build : e4029f9, I6b4cbc7431
Build Date : 10/01/19
OpenGL ES Shader Compiler Version: EV031.27.05.01
Local Branch :
Remote Branch :
Remote Branch :
Reconstruct Branch :
Build Config : S P 8.0.11 AArch64
I/AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
W/AdrenoUtils: <ReadGpuID_from_sysfs:194>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
<ReadGpuID:218>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
W/Gralloc3: mapper 3.x is not supported
I/Choreographer: Skipped 3 frames! The application may be doing too much work on its main thread.
Log
User contributions licensed under CC BY-SA 3.0