Reputation: 89
In my Application, I want to Launch activity within my Tab. So different tab should contain different activity from different projects. Each activity is an imported module project that is build and tested separately. The problem comes when I build my app, it crashes.
MainActivity
package sst1.emily.example.com.sst1;
import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.TabHost;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost host = (TabHost)findViewById(R.id.tabHost);
host.setup();
//Tab 1
TabHost.TabSpec spec = host.newTabSpec("Tab One");
spec.setIndicator("Tab One");
host.addTab(spec);
Intent intent = new Intent();
intent.setClassName("attendance.emily.example.com.attendance", "MainActivity");
spec.setContent(intent);
//Tab 2
spec = host.newTabSpec("Tab Two");
spec.setContent(R.id.tab2);
spec.setIndicator("Tab Two");
host.addTab(spec);
//Tab 3
spec = host.newTabSpec("Tab Three");
spec.setContent(R.id.tab3);
spec.setIndicator("Tab Three");
host.addTab(spec);
} }
Log:
02/05 01:32:48: Launching app
No apk changes detected since last installation, skipping installation of C:\Users\Emily\AndroidStudioProjects\SST1\app\build\outputs\apk\app-debug.apk
$ adb shell am force-stop sst1.emily.example.com.sst1
$ adb shell am start -n "sst1.emily.example.com.sst1/sst1.emily.example.com.sst1.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Connecting to sst1.emily.example.com.sst1
I/System.out: Sending WAIT chunk
W/ActivityThread: Application sst1.emily.example.com.sst1 is waiting for the debugger on port 8100...
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8600', transport: 'socket'
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1493)
I/InstantRun: Instant Run Runtime started. Android package is sst1.emily.example.com.sst1, real application class is null.
W/InstantRun: No instant run dex files added to classpath
W/dalvikvm: VFY: unable to resolve interface method 15998: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
W/dalvikvm: VFY: unable to resolve interface method 16000: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
W/dalvikvm: VFY: unable to resolve interface method 16004: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
W/dalvikvm: VFY: unable to resolve virtual method 686: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
W/dalvikvm: VFY: unable to resolve virtual method 708: Landroid/content/res/TypedArray;.getType (I)I
W/dalvikvm: VFY: unable to resolve virtual method 16431: Landroid/widget/FrameLayout;.startActionModeForChild (Landroid/view/View;Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
W/dalvikvm: VFY: unable to resolve virtual method 419: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
W/dalvikvm: VFY: unable to resolve virtual method 649: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
W/dalvikvm: VFY: unable to resolve virtual method 651: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
W/dalvikvm: VFY: unable to resolve instanceof 148 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper;
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x416abe18)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: sst1.emily.example.com.sst1, PID: 15643
java.lang.RuntimeException: Unable to start activity ComponentInfo{sst1.emily.example.com.sst1/sst1.emily.example.com.sst1.MainActivity}: java.lang.IllegalArgumentException: you must specify a way to create the tab content
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: you must specify a way to create the tab content
at android.widget.TabHost.addTab(TabHost.java:225)
at sst1.emily.example.com.sst1.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:5312)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Any idea which part did I do wrong?
Upvotes: 0
Views: 70
Reputation: 1006674
Activities-in-tabs have been deprecated for six years. They never supported activities coming from other apps.
Upvotes: 1