My Async task runs as it is supposed to and I want to pass an object of arraylists through an intent into the next activity which will update the screen and build some views.
I have my constructor:
Async(BigDecimal balance, Date SD, Integer Years, BigDecimal CPY, Date fPayDate, BigDecimal Nom, String PF, Context context) {
this.balance = balance;
this.SD = SD;
this.Years = Years;
this.CPY = CPY;
this.fPayDate = fPayDate;
this.Nom = Nom;
this.PF = PF;
this.context = context;
}
I try to pass the intent and start the activity:
@Override
protected void onPostExecute(arWrapper wrapper) {
super.onPostExecute(wrapper);
this.balAr = wrapper.balAr;
this.payAr = wrapper.payAr;
this.intAr = wrapper.intAr;
this.dateAr = wrapper.dateAr;
this.prinAr = wrapper.prinAr;
Intent intent = new Intent(context,scrollTable.class)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("balance", new myParcelable(balAr, intAr, dateAr, prinAr, payAr));
context.startActivity(intent);
}
I then try to start the following activity to create a dynamic table layout:
public class scrollTable extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
myParcelable object = getIntent().getParcelableExtra("balance");
ArrayList<BigDecimal> balAr = object.balAr;
ArrayList<BigDecimal> intAr = object.intAr;
ArrayList<Calendar> dateAr = object.dateAr;
ArrayList<BigDecimal> prinAr = object.prinAr;
ArrayList<BigDecimal> payAr = object.payAr;
String[] column = { "Payment", "Interest", "Principal",
"Balance"
};
int rl=balAr.size();
int cl=column.length;
ScrollView sv = new ScrollView(this);
TableLayout tableLayout = createTableLayout(dateAr, column,rl, cl, payAr, intAr, prinAr, balAr);
HorizontalScrollView hsv = new HorizontalScrollView(this);
hsv.addView(tableLayout);
sv.addView(hsv);
setContentView(sv);
}
private TableLayout createTableLayout(ArrayList rv, String [] cv,int rowCount, int columnCount, ArrayList pay, ArrayList intr, ArrayList prin, ArrayList bal)
{
// 1) Create a tableLayout and its params
TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams();
TableLayout tableLayout = new TableLayout(this);
tableLayout.setBackgroundColor(Color.BLACK);
// 2) create tableRow params
TableRow.LayoutParams tableRowParams = new TableRow.LayoutParams();
tableRowParams.setMargins(1, 1, 1, 1);
tableRowParams.weight = 1;
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
for (int i = 0; i < rowCount; i++)
{
// 3) create tableRow
TableRow tableRow = new TableRow(this);
tableRow.setBackgroundColor(Color.BLACK);
for (int j= 0; j < columnCount; j++)
{
// 4) create textView
TextView textView = new TextView(this);
// textView.setText(String.valueOf(j));
textView.setBackgroundColor(Color.WHITE);
textView.setGravity(Gravity.CENTER);
if (i ==0 && j==0)
{
textView.setText("Date");
}
else if(i==0)
{
Log.d("TAG", "set Column Headers");
textView.setText(cv[j-1]);
}
else if( j==0)
{
//set up for dates
Log.d("TAG", "Set Row Headers");
textView.setText(rv.get(i).toString());
}
else if (j == 1)
{
textView.setText(pay.get(i).toString());
}
else if (j == 2)
{
textView.setText(intr.get(i).toString());
}
else if (j == 3)
{
textView.setText(prin.get(i).toString());
}
else if (j == 4)
{
textView.setText(bal.get(i).toString());
}
// 5) add textView to tableRow
tableRow.addView(textView, tableRowParams);
}
// 6) add tableRow to tableLayout
tableLayout.addView(tableRow, tableLayoutParams);
}
return tableLayout;
}
}
Why doesn't the start activity work properly? I don't get any error message and the debug frames just stop as soon as it hits the new activity. I'm also not sure if the main thread can handle all the dynamic creating of the table layout. In addition to why this won't work is there a way to break up the rendering computations?
Edit, there was a log of the events - Logcat:
01-30 13:30:14.462 32279-32279/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 21866747 , only wrote 21713760
01-30 13:30:16.385 32360-516/? I/ActivityManager: START u0 {flg=0x10000000 cmp=dcash.loanschedulecalculator/.scrollTable (has extras)} from uid 10095
01-30 13:30:16.440 9711-9711/dcash.loanschedulecalculator I/Choreographer: Skipped 298 frames! The application may be doing too much work on its main thread.
01-30 13:30:16.461 32360-410/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 743720)
01-30 13:30:16.462 32360-410/? W/ActivityManager: Exception when starting activity dcash.loanschedulecalculator/.scrollTable
android.os.TransactionTooLargeException: data parcel size 743720 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:748)
at android.app.IApplicationThread$Stub$Proxy.scheduleLaunchActivity(IApplicationThread.java:1230)
at com.android.server.am.ActivityStackSupervisor.realStartActivityLocked(ActivityStackSupervisor.java:1467)
at com.android.server.am.ActivityStackSupervisor.startSpecificActivityLocked(ActivityStackSupervisor.java:1571)
at com.android.server.am.ActivityStack.resumeTopActivityInnerLocked(ActivityStack.java:2663)
at com.android.server.am.ActivityStack.resumeTopActivityUncheckedLocked(ActivityStack.java:2215)
at com.android.server.am.ActivityStackSupervisor.resumeFocusedStackTopActivityLocked(ActivityStackSupervisor.java:2062)
at com.android.server.am.ActivityStack.completePauseLocked(ActivityStack.java:1449)
at com.android.server.am.ActivityStack.activityPausedLocked(ActivityStack.java:1375)
at com.android.server.am.ActivityManagerService.activityPaused(ActivityManagerService.java:7251)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:317)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2935)
at android.os.Binder.execTransact(Binder.java:674)
01-30 13:30:16.463 32360-410/? W/ActivityManager: Force removing ActivityRecord{2aa6505 u0 dcash.loanschedulecalculator/.AmortizationSchedule t144}: app died, no saved state
01-30 13:30:16.477 32360-410/? I/ActivityManager: Start proc 9753:dcash.loanschedulecalculator/u0a95 for activity dcash.loanschedulecalculator/.scrollTable
01-30 13:30:16.480 9753-9753/? I/zygote: Not late-enabling -Xcheck:jni (already on)
01-30 13:30:16.507 9753-9753/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
01-30 13:30:16.530 32360-419/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 743720)
01-30 13:30:16.531 32360-419/? E/ActivityManager: Second failure launching dcash.loanschedulecalculator/.scrollTable, giving up
android.os.TransactionTooLargeException: data parcel size 743720 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:748)
at android.app.IApplicationThread$Stub$Proxy.scheduleLaunchActivity(IApplicationThread.java:1230)
at com.android.server.am.ActivityStackSupervisor.realStartActivityLocked(ActivityStackSupervisor.java:1467)
at com.android.server.am.ActivityStackSupervisor.attachApplicationLocked(ActivityStackSupervisor.java:972)
at com.android.server.am.ActivityManagerService.attachApplicationLocked(ActivityManagerService.java:6958)
at com.android.server.am.ActivityManagerService.attachApplication(ActivityManagerService.java:7025)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:291)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2935)
at android.os.Binder.execTransact(Binder.java:674)
01-30 13:30:16.531 32360-419/? I/ActivityManager: Process dcash.loanschedulecalculator (pid 9753) has died: fore TOP
01-30 13:30:16.545 32360-419/? I/ActivityManager: Start proc 9767:dcash.loanschedulecalculator/u0a95 for activity dcash.loanschedulecalculator/.scrollTable
01-30 13:30:16.567 32360-32483/? W/InputDispatcher: channel '88672e0 dcash.loanschedulecalculator/dcash.loanschedulecalculator.AmortizationSchedule (server)' ~ Consumer closed input channel or an error occurred. events=0x9
01-30 13:30:16.567 32360-32483/? E/InputDispatcher: channel '88672e0 dcash.loanschedulecalculator/dcash.loanschedulecalculator.AmortizationSchedule (server)' ~ Channel is unrecoverably broken and will be disposed!
01-30 13:30:16.572 9767-9767/? I/zygote: Not late-enabling -Xcheck:jni (already on)
01-30 13:30:16.599 9767-9767/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
01-30 13:30:16.605 32360-32706/? I/WindowManager: WIN DEATH: Window{88672e0 u0 dcash.loanschedulecalculator/dcash.loanschedulecalculator.AmortizationSchedule}
01-30 13:30:16.605 32360-32706/? W/InputDispatcher: Attempted to unregister already unregistered input channel '88672e0 dcash.loanschedulecalculator/dcash.loanschedulecalculator.AmortizationSchedule (server)'
01-30 13:30:16.627 1395-1395/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8298496
01-30 13:30:16.642 32360-419/? W/ActivityManager: Slow operation: 125ms so far, now at attachApplicationLocked: after mServices.attachApplicationLocked
01-30 13:30:16.653 32360-419/? W/ActivityManager: Slow operation: 136ms so far, now at attachApplicationLocked: after updateOomAdjLocked
01-30 13:30:16.665 32360-32407/? E/ViewRootImpl[loanschedulecalculator]: Attempting to destroy the window while drawing!
window=android.view.ViewRootImpl@9617e17, title=Splash Screen dcash.loanschedulecalculator
01-30 13:30:16.718 1395-1395/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8298496
01-30 13:30:16.725 32360-304/? W/ActivityManager: Slow operation: 59ms so far, now at attachApplicationLocked: after mServices.attachApplicationLocked
01-30 13:30:16.727 32360-304/? W/ActivityManager: Slow operation: 62ms so far, now at attachApplicationLocked: after updateOomAdjLocked
01-30 13:30:16.729 32360-32388/? W/Looper: Dispatch took 204ms on android.ui, h=Handler (com.android.server.am.ActivityManagerService$UiHandler) {452b573} cb=null msg=53
01-30 13:30:16.730 32360-32407/? W/ActivityManager: setHasOverlayUi called on unknown pid: 9711
01-30 13:30:16.752 1395-1395/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8298496
01-30 13:30:16.808 1413-1879/? E/BufferQueueProducer: [Splash Screen dcash.loanschedulecalculator#0] queueBuffer: BufferQueue has been abandoned
01-30 13:30:16.808 32360-32467/? E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -19
01-30 13:30:16.808 32360-32467/? E/Surface: queueBuffer (handle=0x898a4a00) failed (No such device)
01-30 13:30:16.809 1395-1395/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8298496
01-30 13:30:16.811 32360-32467/? E/ViewRootImpl[loanschedulecalculator]: Could not unlock surface
java.lang.IllegalArgumentException
at android.view.Surface.nativeUnlockCanvasAndPost(Native Method)
at android.view.Surface.unlockSwCanvasAndPost(Surface.java:351)
at android.view.Surface.unlockCanvasAndPost(Surface.java:332)
at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:3104)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3007)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2794)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2347)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
at com.android.server.ServiceThread.run(ServiceThread.java:46)