I'm having a simple problem with starting an intent on the click of a button. Unfortunately, i can't find a way out of this problem.
MY first activity java file is :
package com.android.SamsungMIv3;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class SamsungMIv3Activity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(SamsungMIv3Activity.this, currentlocation.class);
SamsungMIv3Activity.this.startActivity(i);
}
});
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:padding="10dp"
>
<Button
android:text="MY LOCATION"
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:padding="10dp"
>
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="ENTER TEXT"
android:id="#+id/textView2">
</TextView>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:padding="10dp"
>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/editText1"
android:inputType="textMultiLine">
<requestFocus></requestFocus>
</EditText>
</ScrollView>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:padding="10dp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="150dp"
android:layout_height="fill_parent"
android:paddingRight="20dp"
>
<Button
android:text="Camera"
android:id="#+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="150dp"
android:layout_height="fill_parent"
>
<Button
android:text="Search Location"
android:id="#+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:padding="10dp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="150dp"
android:layout_height="fill_parent"
android:paddingRight="20dp"
>
<Button
android:text="Facebook"
android:id="#+id/button4"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="150dp"
android:layout_height="fill_parent"
android:paddingRight="20dp"
>
<Button
android:text="Twitter"
android:id="#+id/button5"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Second activity java file :
package com.android.SamsungMIv3;
import android.os.Bundle;
import android.widget.TextView;
import com.google.android.maps.MapActivity;
public class currentlocation extends MapActivity {
#Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.currentlocation);
// TextView t = new TextView(this);
//t.setText("New Activity started");
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
second activity xml file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This works"
android:id="#+id/textView1"></TextView>
</LinearLayout>
manifest file :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.SamsungMIv3"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".SamsungMIv3Activity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".currentlocation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Log Cat :
07-09 14:26:31.352: DEBUG/AndroidRuntime(821): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
07-09 14:26:31.362: DEBUG/AndroidRuntime(821): CheckJNI is ON
07-09 14:26:31.932: DEBUG/AndroidRuntime(821): --- registering native functions ---
07-09 14:26:32.852: DEBUG/ddm-heap(821): Got feature list request
07-09 14:26:33.912: DEBUG/PackageParser(58): Scanning package: /data/app/vmdl72937.tmp
07-09 14:26:33.942: WARN/PackageParser(58): No actions in intent filter at /data/app/vmdl72937.tmp Binary XML file line #20
07-09 14:26:34.202: INFO/PackageManager(58): Removing non-system package:com.android.SamsungMIv3
07-09 14:26:34.202: DEBUG/PackageManager(58): Removing package com.android.SamsungMIv3
07-09 14:26:34.222: DEBUG/PackageManager(58): Activities: com.android.SamsungMIv3.SamsungMIv3Activity com.android.SamsungMIv3.currentlocation
07-09 14:26:34.402: DEBUG/PackageManager(58): Scanning package com.android.SamsungMIv3
07-09 14:26:34.422: INFO/PackageManager(58): /data/app/vmdl72937.tmp changed; unpacking
07-09 14:26:34.452: DEBUG/installd(31): DexInv: --- BEGIN '/data/app/vmdl72937.tmp' ---
07-09 14:26:35.012: DEBUG/dalvikvm(827): DexOpt: load 91ms, verify 109ms, opt 8ms
07-09 14:26:35.062: DEBUG/installd(31): DexInv: --- END '/data/app/vmdl72937.tmp' (success) ---
07-09 14:26:35.072: DEBUG/PackageManager(58): Activities: com.android.SamsungMIv3.SamsungMIv3Activity com.android.SamsungMIv3.currentlocation
07-09 14:26:35.083: DEBUG/ActivityManager(58): Uninstalling process com.android.SamsungMIv3
07-09 14:26:35.332: INFO/installd(31): move /data/dalvik-cache/data#app#vmdl72937.tmp#classes.dex -> /data/dalvik-cache/data#app#com.android.SamsungMIv3.apk#classes.dex
07-09 14:26:35.358: DEBUG/PackageManager(58): New package installed in /data/app/com.android.SamsungMIv3.apk
07-09 14:26:35.562: DEBUG/AndroidRuntime(821): Shutting down VM
07-09 14:26:35.582: DEBUG/dalvikvm(821): DestroyJavaVM waiting for non-daemon threads to exit
07-09 14:26:35.605: DEBUG/dalvikvm(821): DestroyJavaVM shutting VM down
07-09 14:26:35.605: DEBUG/dalvikvm(821): HeapWorker thread shutting down
07-09 14:26:35.622: DEBUG/dalvikvm(821): HeapWorker thread has shut down
07-09 14:26:35.642: DEBUG/jdwp(821): JDWP shutting down net...
07-09 14:26:35.642: INFO/dalvikvm(821): Debugger has detached; object registry had 1 entries
07-09 14:26:35.662: DEBUG/dalvikvm(821): VM cleaning up
07-09 14:26:35.673: ERROR/AndroidRuntime(821): ERROR: thread attach failed
07-09 14:26:35.732: DEBUG/ActivityManager(58): Uninstalling process com.android.SamsungMIv3
07-09 14:26:35.842: DEBUG/dalvikvm(821): LinearAlloc 0x0 used 623012 of 5242880 (11%)
07-09 14:26:36.272: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f0700e5
07-09 14:26:36.286: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f020031
07-09 14:26:36.293: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f020030
07-09 14:26:36.302: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f050000
07-09 14:26:36.432: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f060001
07-09 14:26:36.602: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f060000
07-09 14:26:36.922: DEBUG/dalvikvm(105): GC freed 44 objects / 1752 bytes in 693ms
07-09 14:26:37.482: DEBUG/dalvikvm(58): GC freed 19390 objects / 1061480 bytes in 676ms
07-09 14:26:38.292: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f0700e5
07-09 14:26:38.312: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f020031
07-09 14:26:38.312: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f020030
07-09 14:26:38.322: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f050000
07-09 14:26:38.552: INFO/ActivityManager(58): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=833 uid=10019 gids={}
07-09 14:26:39.573: DEBUG/dalvikvm(58): GC freed 3548 objects / 181408 bytes in 1007ms
07-09 14:26:39.662: DEBUG/AndroidRuntime(832): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
07-09 14:26:39.712: DEBUG/AndroidRuntime(832): CheckJNI is ON
07-09 14:26:39.792: DEBUG/ddm-heap(833): Got feature list request
07-09 14:26:40.354: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f060001
07-09 14:26:40.722: WARN/ResourceType(58): Resources don't contain package for resource number 0x7f060000
07-09 14:26:41.133: DEBUG/AndroidRuntime(832): --- registering native functions ---
07-09 14:26:44.233: INFO/ActivityManager(58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.android.SamsungMIv3/.SamsungMIv3Activity }
07-09 14:26:44.372: DEBUG/AndroidRuntime(832): Shutting down VM
07-09 14:26:44.372: DEBUG/dalvikvm(832): DestroyJavaVM waiting for non-daemon threads to exit
07-09 14:26:44.393: DEBUG/dalvikvm(832): DestroyJavaVM shutting VM down
07-09 14:26:44.412: DEBUG/dalvikvm(832): HeapWorker thread shutting down
07-09 14:26:44.412: DEBUG/dalvikvm(832): HeapWorker thread has shut down
07-09 14:26:44.412: DEBUG/jdwp(832): JDWP shutting down net...
07-09 14:26:44.412: INFO/dalvikvm(832): Debugger has detached; object registry had 1 entries
07-09 14:26:44.432: DEBUG/dalvikvm(832): VM cleaning up
07-09 14:26:44.492: ERROR/AndroidRuntime(832): ERROR: thread attach failed
07-09 14:26:44.842: DEBUG/dalvikvm(832): LinearAlloc 0x0 used 637524 of 5242880 (12%)
07-09 14:26:45.762: DEBUG/ddm-heap(845): Got feature list request
07-09 14:26:45.963: INFO/ActivityManager(58): Start proc com.android.SamsungMIv3 for activity com.android.SamsungMIv3/.SamsungMIv3Activity: pid=845 uid=10032 gids={}
07-09 14:26:47.083: WARN/dalvikvm(845): Unable to resolve superclass of Lcom/android/SamsungMIv3/currentlocation; (17)
07-09 14:26:47.092: WARN/dalvikvm(845): Link of class 'Lcom/android/SamsungMIv3/currentlocation;' failed
07-09 14:26:47.102: ERROR/dalvikvm(845): Could not find class 'com.android.SamsungMIv3.currentlocation', referenced from method com.android.SamsungMIv3.SamsungMIv3Activity$1.onClick
07-09 14:26:47.112: WARN/dalvikvm(845): VFY: unable to resolve const-class 16 (Lcom/android/SamsungMIv3/currentlocation;) in Lcom/android/SamsungMIv3/SamsungMIv3Activity$1;
07-09 14:26:47.112: DEBUG/dalvikvm(845): VFY: replacing opcode 0x1c at 0x0004
07-09 14:26:47.112: DEBUG/dalvikvm(845): Making a copy of Lcom/android/SamsungMIv3/SamsungMIv3Activity$1;.onClick code (48 bytes)
07-09 14:26:47.752: INFO/ActivityManager(58): Displayed activity com.android.SamsungMIv3/.SamsungMIv3Activity: 3402 ms (total 3402 ms)
07-09 14:26:48.102: ERROR/gralloc(58): [unregister] handle 0x4a92b8 still locked (state=40000001)
07-09 14:26:51.414: DEBUG/AndroidRuntime(845): Shutting down VM
07-09 14:26:51.422: WARN/dalvikvm(845): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
07-09 14:26:51.432: ERROR/AndroidRuntime(845): Uncaught handler: thread main exiting due to uncaught exception
07-09 14:26:51.472: ERROR/AndroidRuntime(845): java.lang.NoClassDefFoundError: com.android.SamsungMIv3.currentlocation
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at com.android.SamsungMIv3.SamsungMIv3Activity$1.onClick(SamsungMIv3Activity.java:21)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.View.performClick(View.java:2364)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.View.onTouchEvent(View.java:4179)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.widget.TextView.onTouchEvent(TextView.java:6540)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.View.dispatchTouchEvent(View.java:3709)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.os.Looper.loop(Looper.java:123)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at android.app.ActivityThread.main(ActivityThread.java:4363)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at java.lang.reflect.Method.invoke(Method.java:521)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-09 14:26:51.472: ERROR/AndroidRuntime(845): at dalvik.system.NativeStart.main(Native Method)
07-09 14:26:51.542: INFO/Process(58): Sending signal. PID: 845 SIG: 3
07-09 14:26:51.553: INFO/dalvikvm(845): threadid=7: reacting to signal 3
07-09 14:26:51.602: INFO/dalvikvm(845): Wrote stack trace to '/data/anr/traces.txt'
07-09 14:26:53.502: DEBUG/dalvikvm(105): GC freed 2414 objects / 140960 bytes in 312ms
07-09 14:26:57.862: INFO/Process(845): Sending signal. PID: 845 SIG: 9
07-09 14:26:58.053: INFO/ActivityManager(58): Process com.android.SamsungMIv3 (pid 845) has died.
07-09 14:26:58.073: INFO/WindowManager(58): WIN DEATH: Window{44d6f5c0 com.android.SamsungMIv3/com.android.SamsungMIv3.SamsungMIv3Activity paused=false}
07-09 14:26:58.292: INFO/UsageStats(58): Unexpected resume of com.android.launcher while already resumed in com.android.SamsungMIv3
07-09 14:26:58.532: WARN/InputManagerService(58): Got RemoteException sending setActive(false) notification to pid 845 uid 10032
I understand that the loc cat points to an error at the line
Intent i = new Intent(...);
But I'm not able to find a way to resolve this problem
Your activity depends on MapActivity, but you have not included these dependent classes in your app. See: "Unable to resolve superclass of Lcom/android/SamsungMIv3/currentlocation"
It seems that you manifest need too clarify that you'll use map lib
<uses-library android:name="com.google.android.maps" />
Try removing the following from your manifest.xml in the currentLocation activity:
<category android:name="android.intent.category.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /
There should only be one main and one launcher class. Perhaps that's it.
If you are using android studio try
./gradlew clean && ./gradlew build
Look for build.gradle in your application directory
//build.gradle
n check under dependencies whether ur file is included or not
e.g
dependencies {
compile 'com.android.support:support-v13:18.0.0'
}
I wanted to add support v-13 files so I added the same in compile path and same files
should be there in support library of SDK. e.g.
sdk/extras/android/support/v13/android-support-v13.jar
In eclipse, I think you have to look under JAVA-BUILD path.
Related
I am making app which on portrait mode shows fragmentA (containing Listview) and when in Landscape mode, it shows fragmentA and fragmentB(Listview and its corresponding description).It keeps on crashing,my hunch says either there is a fault in if-else condition in MainActivity or problem is in communication pattern.I request Everyone to please Help. Here is my MainActivity.xml
package com.example.prince.fragment_modularui2;
import android.content.Intent;
import android.content.res.Resources;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity implements FragmentA.Communicator{
String s;
Resources r=getResources();
String[] a=r.getStringArray(R.array.descr);
FragmentA fa;
FragmentB fb;
FragmentManager manager;
#Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
manager=getSupportFragmentManager();
//fa always present
fa= (FragmentA) manager.findFragmentById(R.id.fragment);
fb= (FragmentB) manager.findFragmentById(R.id.fragment2);
fa.setCommunicator(this);
}
#Override
public void respond(int data) {
Intent i=new Intent(this,AnotherActivity.class);
i.putExtra("index",data);
startActivity(i);
}
}
here is activity_main.xml in Portrait
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.prince.fragment_modularui2.FragmentA"
android:id="#+id/fragment"
></fragment>
</LinearLayout>
activity_main in landscape
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<fragment
android:id="#+id/fragment"
android:name="com.example.prince.fragment_modularui2.FragmentA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true" />
<fragment
android:id="#+id/fragment2"
android:name="com.example.prince.fragment_modularui2.FragmentB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" />
</LinearLayout>
Rest of the code is https://github.com/AlmightyHeathcliff/Fragment_ModularUi2
The stackTrace is
07-18 09:45:09.252 1974-1974/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:09.254 1974-1974/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:09.289 1974-1974/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:09.301 1974-1974/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:09.316 1974-1974/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:09.316 1974-1974/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:09.317 1974-1974/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:09.325 1974-1974/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
07-18 09:45:09.330 1974-1974/? I/art: System.exit called, status: 0
07-18 09:45:09.330 1974-1974/? I/AndroidRuntime: VM exiting with result code 0.
07-18 09:45:09.333 1974-1982/? W/MessageQueue: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:643)
at android.os.Handler.sendMessageAtTime(Handler.java:612)
at android.os.Handler.sendMessageDelayed(Handler.java:582)
at android.os.Handler.post(Handler.java:338)
at android.os.ResultReceiver$MyResultReceiver.send(ResultReceiver.java:57)
at com.android.internal.os.IResultReceiver$Stub.onTransact(IResultReceiver.java:58)
at android.os.Binder.execTransact(Binder.java:565)
07-18 09:45:09.972 1993-1993/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:09.976 1993-1993/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:10.012 1993-1993/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:10.015 1993-1993/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:10.049 1993-1993/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:10.049 1993-1993/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:10.050 1993-1993/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:10.059 1993-1993/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
07-18 09:45:10.064 1993-2001/? W/MessageQueue: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:643)
at android.os.Handler.sendMessageAtTime(Handler.java:612)
at android.os.Handler.sendMessageDelayed(Handler.java:582)
at android.os.Handler.post(Handler.java:338)
at android.os.ResultReceiver$MyResultReceiver.send(ResultReceiver.java:57)
at com.android.internal.os.IResultReceiver$Stub.onTransact(IResultReceiver.java:58)
at android.os.Binder.execTransact(Binder.java:565)
07-18 09:45:10.064 1993-1993/? I/art: System.exit called, status: 0
07-18 09:45:10.064 1993-1993/? I/AndroidRuntime: VM exiting with result code 0.
07-18 09:45:13.487 2005-2005/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:13.491 2005-2005/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:13.569 2005-2005/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:13.575 2005-2005/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:13.708 2009-2009/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:13.715 2009-2009/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:13.760 2005-2005/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:13.760 2005-2005/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:13.761 2005-2005/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:13.776 2005-2005/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
07-18 09:45:13.814 2009-2009/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:13.825 2009-2009/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:13.833 2005-2005/? D/AndroidRuntime: Shutting down VM
07-18 09:45:13.839 2005-2019/? W/art: Thread attaching while runtime is shutting down: Binder:2005_2
07-18 09:45:13.839 2005-2019/? I/AndroidRuntime: NOTE: attach of thread 'Binder:2005_2' failed
07-18 09:45:13.891 2009-2009/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:13.891 2009-2009/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:13.892 2009-2009/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:13.903 2009-2009/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
07-18 09:45:13.909 765-1149/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.prince.fragment_modularui2/.MainActivity} from uid 0 on display 0
07-18 09:45:13.919 2009-2009/? D/AndroidRuntime: Shutting down VM
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: returned from zygote!
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done updating battery stats
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: building log message
07-18 09:45:13.993 765-1021/system_process I/ActivityManager: Start proc 2027:com.example.prince.fragment_modularui2/u0a115 for activity com.example.prince.fragment_modularui2/.MainActivity
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: starting to update pids map
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done updating pids map
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done starting proc!
07-18 09:45:14.003 2027-2027/? I/art: Late-enabling -Xcheck:jni
07-18 09:45:14.004 2027-2027/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:14.258 500-757/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x933 imply creation of host color buffer
07-18 09:45:14.784 2027-2027/com.example.prince.fragment_modularui2 W/System: ClassLoader referenced unknown path: /data/app/com.example.prince.fragment_modularui2-1/lib/x86
07-18 09:45:14.813 2027-2027/com.example.prince.fragment_modularui2 I/InstantRun: starting instant run server: is main process
07-18 09:45:14.814 2027-2027/com.example.prince.fragment_modularui2 V/InstantRun: Starting server socket listening for package com.example.prince.fragment_modularui2 on android.net.LocalSocketAddress#8989009
07-18 09:45:14.814 2027-2027/com.example.prince.fragment_modularui2 V/InstantRun: Started server for package com.example.prince.fragment_modularui2
07-18 09:45:14.903 2027-2027/com.example.prince.fragment_modularui2 D/AndroidRuntime: Shutting down VM
07-18 09:45:14.904 2027-2027/com.example.prince.fragment_modularui2 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.prince.fragment_modularui2, PID: 2027
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.prince.fragment_modularui2/com.example.prince.fragment_modularui2.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
at android.content.ContextWrapper.getResources(ContextWrapper.java:86)
at android.view.ContextThemeWrapper.getResourcesInternal(ContextThemeWrapper.java:127)
at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:121)
at android.support.v7.app.AppCompatActivity.getResources(AppCompatActivity.java:549)
at com.example.prince.fragment_modularui2.MainActivity.<init>(MainActivity.java:12)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
07-18 09:45:14.907 765-1021/system_process W/ActivityManager: Force finishing activity com.example.prince.fragment_modularui2/.MainActivity
07-18 09:45:15.031 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.058 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.115 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.232 765-1842/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
07-18 09:45:15.232 765-1842/system_process D/OpenGLRenderer: Swap behavior 1
07-18 09:45:15.429 765-779/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}
07-18 09:45:15.431 765-779/system_process I/ActivityManager: Killing 1353:android.process.media/u0a10 (adj 906): empty #17
07-18 09:45:15.432 765-779/system_process I/WindowManager: Failed to capture screenshot of Token{7756ed3 ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}} appWin=Window{7f1e54b u0 Starting com.example.prince.fragment_modularui2} drawState=1
07-18 09:45:15.448 765-786/system_process I/Choreographer: Skipped 70 frames! The application may be doing too much work on its main thread.
07-18 09:45:15.452 765-1150/system_process D/ActivityManager: cleanUpApplicationRecord -- 1353
07-18 09:45:15.456 765-1842/system_process E/EGL_emulation: tid 1842: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
07-18 09:45:15.456 765-1842/system_process W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xc4afa800, error=EGL_BAD_MATCH
07-18 09:45:16.337 765-780/system_process I/Choreographer: Skipped 52 frames! The application may be doing too much work on its main thread.
07-18 09:45:25.438 765-779/system_process W/ActivityManager: Activity destroy timeout for ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}
From the stacktrace I gather that you are calling getResources() on a Context that is null. This makes sense because you are declaring your resources as a field like:
Resources res = getResources();
This gets executed before the activity is created but you can only call getResources() once the activity is created. So the solution is to declare your resources like:
private Resources res;
And in your activity onCreate method you do:
res = getResources();
This also means that you can't use the res variable until the onCreate method is executed. Generally it is better to not declare resources as a variable like that but rather declare your string array as:
String[] a;
and then in onCreate just call: a = getResources().getStringArray(R.array.desc);
One other tip I can give you is to name your variable clearer. A string array named 'a' is not very descriptive. You can call it something like descriptionArray to make it more clear.
I am trying to get nested viewflippers set up with the following setup
Top_ViewFlipper
- Type 1
Sub_ViewFlipper
- SubType 1
- SubType 2
- SubType 3
- Type 2
Sub_ViewFlipper
- SubType 1
- SubType 2
- SubType 3
Source can be found here: https://github.com/platinummonkey/TXLF-App/tree/master/android
The following links contain all the XML and source relevant to this problem (instead of viewing a wall of text):
sessions.xml (main xml)
session_day0.xml
session_day1.xml
session_track.xml
session_two_line_list.xml
Sessions.java
SessionListAdapter.java
Trace of Current Error:
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
D/KeyguardViewMediator( 981): wakeWhenReadyLocked(26)
I/power ( 981): *** set_screen_state 1
V/$$$$$$ ( 8060): In Method: ACTION_SCREEN_ON
V/$$$$$$ ( 8060): In service onStart: REGISTERED RECEIVER
D/SurfaceFlinger( 981): Screen about to return, flinger = 0x95b38
V/$$$$$$ ( 8060): In Method: ACTION_USER_PRESENT
I/ActivityManager( 981): Start proc com.android.settings for broadcast com.android.settings/.widget.SettingsAppWidgetProvider: pid=8945 uid=1000 gids={1015, 3002, 3001, 3003}
W/InputManagerService( 981): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#40699050
D/szipinf ( 8945): Initializing inflate state
V/$$$$$$ ( 8060): In service onStart: REGISTERED RECEIVER
D/szipinf ( 8945): Initializing inflate state
D/SettingsAppWidgetProvider( 8945): Widget is from a previous version... Let's update
D/SettingsAppWidgetProvider( 8945): No instances yet... Wait for at least one instance to exist before adding global settings
I/ActivityManager( 981): No longer want com.anod.calendar (pid 8541): hidden #16
W/ActivityManager( 981): Scheduling restart of crashed service com.anod.calendar/.services.UpdateService in 5000ms
I/ActivityManager( 981): Start proc com.anod.calendar for service com.anod.calendar/.services.UpdateService: pid=8953 uid=10083 gids={1015}
D/dalvikvm( 967): GC_EXPLICIT freed 12K, 51% free 2674K/5379K, external 0K/0K, paused 133ms
D/szipinf ( 8953): Initializing inflate state
I/ActivityThread( 8953): Pub com.anod.calendar.events.provider: com.anod.calendar.scrollable.ScrollableDataProvider
I/dalvikvm( 8953): Could not find method android.appwidget.AppWidgetManager.notifyAppWidgetViewDataChanged, referenced from method com.anod.calendar.services.UpdateService.updateWidgets
D/dalvikvm( 967): GC_EXPLICIT freed <1K, 51% free 2674K/5379K, external 0K/0K, paused 63ms
W/dalvikvm( 8953): VFY: unable to resolve virtual method 151: Landroid/appwidget/AppWidgetManager;.notifyAppWidgetViewDataChanged ([II)V
D/dalvikvm( 8953): VFY: replacing opcode 0x6e at 0x0024
D/SimpleCal( 8953): Register content observer : 0
D/SimpleCal( 8953): Unregister content observer : 1
D/SimpleCal( 8953): Unregister content observer : 2
D/dalvikvm( 967): GC_EXPLICIT freed <1K, 51% free 2674K/5379K, external 0K/0K, paused 45ms
D/SimpleCal( 8953): Register content observer : 0
D/SimpleCal( 8953): Unregister content observer : 1
D/SimpleCal( 8953): Unregister content observer : 2
D/AndroidRuntime( 8964):
D/AndroidRuntime( 8964): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
I/AndroidRuntime( 8964): Heap size: -Xmx32m
D/AndroidRuntime( 8964): CheckJNI is OFF
D/dalvikvm( 8964): creating instr width table
D/AndroidRuntime( 8964): Calling main entry com.android.commands.pm.Pm
D/AndroidRuntime( 8964): Shutting down VM
D/dalvikvm( 8964): GC_CONCURRENT freed 103K, 70% free 307K/1024K, external 0K/0K, paused 0ms+1ms
D/dalvikvm( 8964): Debugger has detached; object registry had 1 entries
I/AndroidRuntime( 8964): NOTE: attach of thread 'Binder Thread #3' failed
D/AndroidRuntime( 8974):
D/AndroidRuntime( 8974): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
I/AndroidRuntime( 8974): Heap size: -Xmx32m
D/AndroidRuntime( 8974): CheckJNI is OFF
D/dalvikvm( 8974): creating instr width table
D/AndroidRuntime( 8974): Calling main entry com.android.commands.am.Am
I/ActivityManager( 981): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=org.texaslinuxfest.txlf/.TxlfActivity } from pid 8974
I/ActivityManager( 981): Start proc org.texaslinuxfest.txlf for activity org.texaslinuxfest.txlf/.TxlfActivity: pid=8982 uid=10100 gids={3003, 1006}
D/AndroidRuntime( 8974): Shutting down VM
D/dalvikvm( 8974): GC_CONCURRENT freed 103K, 69% free 325K/1024K, external 0K/0K, paused 0ms+1ms
D/dalvikvm( 8974): Debugger has detached; object registry had 1 entries
I/AndroidRuntime( 8974): NOTE: attach of thread 'Binder Thread #3' failed
E/jdwp ( 8982): Failed sending reply to debugger: Broken pipe
D/dalvikvm( 8982): Debugger has detached; object registry had 1 entries
D/szipinf ( 8982): Initializing inflate state
D/dalvikvm( 8982): GC_EXTERNAL_ALLOC freed 44K, 50% free 2692K/5379K, external 0K/0K, paused 56ms
V/txlf ( 8982): App already installed on your phone
D/txlf ( 8982): Guide hasn't expired
V/txlf ( 8982): Guide is ready - Sessions available
I/ActivityManager( 981): Displayed org.texaslinuxfest.txlf/.TxlfActivity: +406ms (total +4m46s12ms)
V/$$$$$$ ( 8060): In service onStart: REGISTERED RECEIVER
I/ActivityManager( 981): Starting: Intent { cmp=org.texaslinuxfest.txlf/.Sessions (has extras) } from pid 8982
D/Sessions Activity( 8982): Got guide through intent Serializable
W/ResourceType( 8982): getEntry failing because entryIndex 12 is beyond type entryCount 12
W/ResourceType( 8982): Failure getting entry for 0x7f03000c (t=2 e=12) in package 0 (error -2147483647)
D/AndroidRuntime( 8982): Shutting down VM
W/dalvikvm( 8982): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime( 8982): FATAL EXCEPTION: main
E/AndroidRuntime( 8982): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.texaslinuxfest.txlf/org.texaslinuxfest.txlf.Sessions}: android.content.res.Resources$NotFoundException: Resource ID #0x7f03000c
E/AndroidRuntime( 8982): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
E/AndroidRuntime( 8982): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
E/AndroidRuntime( 8982): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
E/AndroidRuntime( 8982): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
E/AndroidRuntime( 8982): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 8982): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 8982): at android.app.ActivityThread.main(ActivityThread.java:3835)
E/AndroidRuntime( 8982): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 8982): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 8982): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
E/AndroidRuntime( 8982): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
E/AndroidRuntime( 8982): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 8982): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f03000c
E/AndroidRuntime( 8982): at android.content.res.Resources.getValue(Resources.java:929)
E/AndroidRuntime( 8982): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1955)
E/AndroidRuntime( 8982): at android.content.res.Resources.getLayout(Resources.java:768)
E/AndroidRuntime( 8982): at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
E/AndroidRuntime( 8982): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
E/AndroidRuntime( 8982): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212)
E/AndroidRuntime( 8982): at android.app.Activity.setContentView(Activity.java:1657)
E/AndroidRuntime( 8982): at org.texaslinuxfest.txlf.Sessions.onCreate(Sessions.java:70)
E/AndroidRuntime( 8982): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 8982): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
E/AndroidRuntime( 8982): ... 11 more
W/ActivityManager( 981): Force finishing activity org.texaslinuxfest.txlf/.Sessions
W/ActivityManager( 981): Force finishing activity org.texaslinuxfest.txlf/.TxlfActivity
W/ActivityManager( 981): Activity pause timeout for HistoryRecord{40708c48 org.texaslinuxfest.txlf/.Sessions}
I/ActivityManager( 981): No longer want com.android.defcontainer (pid 8900): hidden #16
I/Process ( 8982): Sending signal. PID: 8982 SIG: 9
I/ActivityManager( 981): Process org.texaslinuxfest.txlf (pid 8982) has died.
I/WindowManager( 981): WIN DEATH: Window{407c4aa8 org.texaslinuxfest.txlf/org.texaslinuxfest.txlf.TxlfActivity paused=true}
D/dalvikvm( 981): GC_CONCURRENT freed 1979K, 51% free 7640K/15431K, external 3673K/3889K, paused 12ms+11ms
Right Now it just errors out, two commits prior I had one primary Viewflipper working, but nesting it seems to have broken things... even after manually adding listviews to the nested viewflipper (instead of using a generic method).
I am having trouble assigning assigning the SubTypes to the appropriate subViewflipper. Does anyone have an example of this either XML or programmatically? I have yet to find any examples on using nested viewflippers. Optionally tab host might work, but I would prefer text-only buttons and do like the animations that come with viewflipper.
GITHUB repo: https://github.com/agoransson/nested_view_flippers
Okay, this will be a big answer... but I hope it's what you were looking for.
The activity:
private GestureDetector gestureScanner;
private ViewFlipper rootFlipper;
private ViewFlipper flipper1, flipper2;
private Animation animFlipInNext, animFlipOutNext;
private Animation animFlipInPrevious, animFlipOutPrevious;
private Animation rootAnimFlipInNext, rootAnimFlipOutNext;
private Animation rootAnimFlipInPrevious, rootAnimFlipOutPrevious;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Root flipper
rootFlipper = (ViewFlipper) findViewById(R.id.rootFlipper);
// Content flippers
flipper1 = (ViewFlipper) findViewById(R.id.viewFlipper1);
flipper2 = (ViewFlipper) findViewById(R.id.viewFlipper2);
gestureScanner = new GestureDetector(this);
// Animations
animFlipInNext = AnimationUtils.loadAnimation(this, R.anim.flipinnext);
animFlipOutNext = AnimationUtils.loadAnimation(this, R.anim.flipoutnext);
animFlipInPrevious = AnimationUtils.loadAnimation(this,
R.anim.flipinprevious);
animFlipOutPrevious = AnimationUtils.loadAnimation(this,
R.anim.flipoutprevious);
rootAnimFlipInNext = AnimationUtils.loadAnimation(this,
R.anim.rootflipinnext);
rootAnimFlipOutNext = AnimationUtils.loadAnimation(this,
R.anim.rootflipoutnext);
rootAnimFlipInPrevious = AnimationUtils.loadAnimation(this,
R.anim.rootflipinprevious);
rootAnimFlipOutPrevious = AnimationUtils.loadAnimation(this,
R.anim.rootflipoutprevious);
}
#Override
public boolean onTouchEvent(MotionEvent event) {
return gestureScanner.onTouchEvent(event);
}
#Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
Log.i("TEST", "Fling!!");
if (Math.abs(velocityY) > Math.abs(velocityX)) {
if (velocityY > 0) {
rootFlipper.setInAnimation(rootAnimFlipInNext);
rootFlipper.setOutAnimation(rootAnimFlipOutNext);
rootFlipper.showNext();
} else if (velocityY < 0) {
rootFlipper.setInAnimation(rootAnimFlipInPrevious);
rootFlipper.setOutAnimation(rootAnimFlipOutPrevious);
rootFlipper.showPrevious();
}
} else {
if (velocityX > 0) {
ViewFlipper v = (ViewFlipper) rootFlipper.getCurrentView();
v.setInAnimation(animFlipInNext);
v.setOutAnimation(animFlipOutNext);
v.showNext();
} else if (velocityX < 0) {
ViewFlipper v = (ViewFlipper) rootFlipper.getCurrentView();
v.setInAnimation(animFlipInPrevious);
v.setOutAnimation(animFlipOutPrevious);
v.showPrevious();
}
}
return true;
}
The layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ViewFlipper
android:id="#+id/rootFlipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ViewFlipper
android:id="#+id/viewFlipper1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/innerone"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff0000"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LAYOUT 1-1"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:id="#+id/innertwo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff0000"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LAYOUT 1-2"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:id="#+id/innerthree"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff0000"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LAYOUT 1-3"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</ViewFlipper>
<ViewFlipper
android:id="#+id/viewFlipper2"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/innerone"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00ff00"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LAYOUT 2-1"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:id="#+id/innertwo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00ff00"
android:orientation="vertical" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LAYOUT 2-2"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:id="#+id/innerthree"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00ff00"
android:orientation="vertical" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LAYOUT 2-3"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</ViewFlipper>
</ViewFlipper>
</LinearLayout>
The animations:
flipinnext.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/decelerate_interpolator" >
<translate
android:duration="500"
android:fromXDelta="-100%"
android:toXDelta="0%" />
</set>
flipinprevious.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/decelerate_interpolator" >
<translate
android:duration="500"
android:fromXDelta="100%"
android:toXDelta="0%" />
</set>
flipoutnext.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/decelerate_interpolator" >
<translate
android:duration="500"
android:fromXDelta="0%"
android:toXDelta="100%" />
</set>
flipoutprevious.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/decelerate_interpolator" >
<translate
android:duration="500"
android:fromXDelta="0%"
android:toXDelta="-100%" />
</set>
And then you need a set of almost identical animations for the root flip (y-axis). Just copy the x-axis animations and change the translate attributes to the Y-axis.
D/AndroidRuntime(11752):
D/AndroidRuntime(11752): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(11752): CheckJNI is ON
D/dalvikvm(11752): creating instr width table
E/jdwp (11752): pipe failed
W/ProcessState(11752): Opening '/dev/binder' failed: Too many open files
D/AndroidRuntime(11752): Calling main entry com.android.commands.am.Am
I/Mamarduke_Diag( 1726): Data is available now.
I/Mamarduke_Diag( 1726): exec result -->>> java.lang.NullPointerException
I/DMIC ( 1726): ---> java.lang.NullPointerException
I/System.out( 1726): *****wifi state end=1
D/dalvikvm( 1726): GC_EXPLICIT freed 31K, 41% free 7507K/12551K, external 1625K/2137K, paused 58ms
D/dalvikvm( 1726): GC_EXPLICIT freed 0K, 41% free 7507K/12551K, external 1625K/2137K, paused 58ms
I/System.out( 1726): ***run in test i=7,camera
I/System.out( 1726): ***run in test i=8,cec
I/System.out( 1726): ***run in test i=9,edid
I/System.out( 1726): *****wifi state start=1
I/Mamarduke_Diag( 1726): Data is available now.
I/Mamarduke_Diag( 1726): exec result -->>>
I/System.out( 1726): *****wifi state end=1
D/dalvikvm( 1726): GC_EXPLICIT freed 36K, 41% free 7474K/12551K, external 1625K/2137K, paused 57ms
D/dalvikvm( 1726): GC_EXPLICIT freed 0K, 41% free 7474K/12551K, external 1625K/2137K, paused 58ms
I/System.out( 1726): ***run in test i=10,iris
I/System.out( 1726): *****wifi state start=1
I/ActivityManager( 1491): Starting: Intent { act=com.android.camera.irison flg=0x10000000 cmp=com.ianc.apd/.testcase.cameraex.ImageCamera } from pid 1726
I/System.out( 1726): onCreate
I/System.out( 1726): onResume
I/System.out( 1726): test irist on
I/System.out( 1726): excuteCmd/sys/bus/spi/devices/spi2.0/irisstate
E/InputDispatcher( 1491): channel '40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera (server)' ~ Consumer closed input channel or an error occurred. events=0x8
E/InputDispatcher( 1491): channel '40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera (server)' ~ Channel is unrecoverably broken and will be disposed!
D/AndroidRuntime( 1726): Shutting down VM
W/dalvikvm( 1726): threadid=1: thread exiting with uncaught exception (group=0x40015560)
I/WindowManager( 1491): WINDOW DIED Window{40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera paused=false}
E/AndroidRuntime( 1726): FATAL EXCEPTION: main
E/AndroidRuntime( 1726): java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
E/AndroidRuntime( 1726): at android.view.InputChannel.nativeReadFromParcel(Native Method)
E/AndroidRuntime( 1726): at android.view.InputChannel.readFromParcel(InputChannel.java:138)
E/AndroidRuntime( 1726): at android.view.IWindowSession$Stub$Proxy.add(IWindowSession.java:409)
E/AndroidRuntime( 1726): at android.view.ViewRoot.setView(ViewRoot.java:498)
E/AndroidRuntime( 1726): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
E/AndroidRuntime( 1726): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/AndroidRuntime( 1726): at android.view.Window$LocalWindowManager.addView(Window.java:424)
E/AndroidRuntime( 1726): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2170)
E/AndroidRuntime( 1726): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
E/AndroidRuntime( 1726): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 1726): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 1726): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1726): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 1726): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 1726): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1726): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 1726): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 1726): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 1726): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 1491): Force finishing activity com.ianc.apd/.testcase.cameraex.ImageCamera
W/ActivityManager( 1491): Activity pause timeout for HistoryRecord{4069a248 com.ianc.apd/.testcase.cameraex.ImageCamera}
Why do Consumer closed input channel or an error occurred. events=0x8 happen after many times running? That is too say, my program can run at first, but after many times, the exception happen.
I read this: Input transport and input dispatcher error on 2.3, but I have no idea how to solve it!! Who can help me?
I run my program in real device. The android version is 2.3
Update 1:
I found the root cause of Could not read input channel file descriptors from parcel.
It is E/jdwp (11752): pipe failed.
Why do create pipe failed? Because the pipe is out of the max in the system. that is to say, we create a lot of pipe or file descriptors in the system. And then we found the reason and try to modify it: My friend change the code like that in his Activity: `Original source code:
private class MyHandler extends Handler {
MyHandler(Looper looper) {
super(looper);
}
#Override
public void handleMessage(Message msg) {
switch(msg.what) {
case RELEASE_CAMERA:
synchronized (CameraHolder.this) {
// In 'CameraHolder.open', the 'RELEASE_CAMERA' message
// will be removed if it is found in the queue. However,
// there is a chance that this message has been handled
// before being removed. So, we need to add a check
// here:
if (CameraHolder.this.mUsers == 0) releaseCamera();
}
break;
}
}
}
...
HandlerThread ht = new HandlerThread("CameraHolder");
ht.start();
mHandler = new MyHandler(ht.getLooper());
change to
private class MyHandler extends Handler {
MyHandler(Looper looper) {
super(looper);
}
#Override
public void handleMessage(Message msg) {
switch(msg.what) {
case RELEASE_CAMERA:
synchronized (CameraHolder.this) {
// In 'CameraHolder.open', the 'RELEASE_CAMERA' message
// will be removed if it is found in the queue. However,
// there is a chance that this message has been handled
// before being removed. So, we need to add a check
// here:
if (CameraHolder.this.mUsers == 0) releaseCamera();
}
break;
}
}
}
mHandler = new MyHandler();
Those file descriptors will reduce obviously. Why? how to explain this case? And I add mHandler.removemessage this function to onPause in my Activity. And Those file descriptors also reduce obviously. why? who can explain this case for me? I am trying to understand this.
Benni05 found a solution here, by setting android:configChanges="orientation" property for activity #AndroidManifest. It work for me(where i get an error with api lvl.11 installed devices). Good luck!
it is most probably because of having a wrong xml resource file. for me i put colors in strings.xml and got this errors. then i created colors.xml and now it works.
Problem is simple.
Two Activities. One throwing intent at other.
Project have name : "Stupidroid"
package : "com.examples.stupidroid"
activity : "stupidOnSteroids"
below is stupidOnSteroids .java
package com.examples.stupidroid;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class stupidOnSteroids extends Activity {
private Button buttonThatWillTakeYouPlacesButton;
private Intent intentThatwillTakeYouPlacesIntent;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InitLayouts();
InitSetOnClickListeners();
}
private void InitSetOnClickListeners() {
buttonThatWillTakeYouPlacesButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
intentThatwillTakeYouPlacesIntent.setAction("");
}
});
}
private void InitLayouts() {
buttonThatWillTakeYouPlacesButton = (Button)findViewById(R.id.buttonThatWillGiveThyPowerButton);
intentThatwillTakeYouPlacesIntent = new Intent(stupidOnSteroids.this, Calc_print_codefile.class);
}
}
now is main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
>
<Button android:id="#+id/goToOtherMoronButton"
android:text="Next Activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
></Button>
</LinearLayout>
now is another java file : Calc_print_codefile.java
package com.examples.stupidroid;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Calc_print_codefile extends Activity{
Button buttonThatWillHelpYouCalculateButton;
TextView textThatWillTakeTheHitText;
Button buttonThatWillTakeYouHomeButton;
Intent intentThatWillTakeYouHomeIntent;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.calc_prin_layout);
InitLayouts();
InitSetOnClickListener();
}
private void InitSetOnClickListener() {
buttonThatWillHelpYouCalculateButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
for(int i=0; i<32000; i++){
textThatWillTakeTheHitText.setText(i);
}
}
});
}
private void InitLayouts() {
buttonThatWillHelpYouCalculateButton = (Button)findViewById(R.id.buttonThatWillGiveThyPowerButton);
textThatWillTakeTheHitText = (TextView)findViewById(R.id.textThatWillAbsolveThyText);
intentThatWillTakeYouHomeIntent = new Intent(Calc_print_codefile.this, stupidOnSteroids.class);
}
}
corresponding xml : calc_prin_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="#+id/textThatWillAbsolveThyText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=" "
/>
<Button android:id="#+id/buttonThatWillGiveThyPowerButton"
android:text="Press ME, hard!"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></Button>
</LinearLayout>
below is AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examples.stupidroid"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".stupidOnSteroids"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Calc_print_codefile"></activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
Here are images (actually one only):
now is information from DDMS
07-29 14:13:31.344: WARN/ActivityThread(379): Application com.examples.stupidroid is waiting for the debugger on port 8100...
07-29 14:13:31.374: INFO/System.out(379): Sending WAIT chunk
07-29 14:13:31.434: INFO/dalvikvm(379): Debugger is active
07-29 14:13:31.594: INFO/System.out(379): Debugger has connected
07-29 14:13:31.604: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:31.804: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:31.824: DEBUG/dalvikvm(33): GC_EXPLICIT freed 2 objects / 64 bytes in 556ms
07-29 14:13:32.038: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:32.296: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:32.444: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{440534a8 com.examples.stupidroid/.stupidOnSteroids}
07-29 14:13:32.494: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:32.694: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:32.894: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:33.113: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:33.356: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:33.574: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:33.795: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.008: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.215: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.423: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.634: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.868: INFO/System.out(379): debugger has settled (1504)
07-29 14:13:40.587: WARN/ActivityManager(60): Launch timeout has expired, giving up wake lock!
07-29 14:13:41.254: WARN/ActivityManager(60): Activity idle timeout for HistoryRecord{44078b28 com.examples.stupidroid/.stupidOnSteroids}
07-29 14:13:46.454: DEBUG/dalvikvm(135): GC_EXPLICIT freed 1190 objects / 62584 bytes in 179ms
07-29 14:13:57.363: DEBUG/dalvikvm(60): GC_FOR_MALLOC freed 12320 objects / 698248 bytes in 153ms
07-29 14:13:58.423: DEBUG/AndroidRuntime(379): Shutting down VM
07-29 14:13:58.423: WARN/dalvikvm(379): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
**07-29 14:13:58.543: ERROR/AndroidRuntime(379): FATAL EXCEPTION: main
07-29 14:13:58.543: ERROR/AndroidRuntime(379): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.examples.stupidroid/com.examples.stupidroid.stupidOnSteroids}: java.lang.NullPointerException**
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.os.Looper.loop(Looper.java:123)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at java.lang.reflect.Method.invokeNative(Native Method)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at java.lang.reflect.Method.invoke(Method.java:521)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at dalvik.system.NativeStart.main(Native Method)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): Caused by: java.lang.NullPointerException
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at com.examples.stupidroid.stupidOnSteroids.InitSetOnClickListeners(stupidOnSteroids.java:20)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at com.examples.stupidroid.stupidOnSteroids.onCreate(stupidOnSteroids.java:17)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): ... 11 more
07-29 14:13:58.613: WARN/ActivityManager(60): Force finishing activity com.examples.stupidroid/.stupidOnSteroids
07-29 14:13:59.128: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{44078b28 com.examples.stupidroid/.stupidOnSteroids}
07-29 14:14:09.273: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{44078b28 com.examples.stupidroid/.stupidOnSteroids}
07-29 14:14:13.443: INFO/Process(379): Sending signal. PID: 379 SIG: 9
07-29 14:14:13.465: INFO/ActivityManager(60): Process com.examples.stupidroid (pid 379) has died.
07-29 14:14:13.483: WARN/InputManagerService(60): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#43ef9a68
Please tell me what can I do? I have followed same approach the other guy followed. My other project is working. what can it be? is it wrong nomenclature or what?
From my past experiences, it looks like very small very narrow mistake , might be silly, still can't put my finger at it.
Thanks for spending time reading this.
And oh, if I remove InitSetOnClickListeners(); from stupidOnSteroids.java file, I can at least see a button. So, there might be error.
You initializing of your button is wrong. In your main xml you don't have a button with the id R.id.buttonThatWillGiveThyPowerButton. You should change it to
R.id.goToOtherMoronButton.
You should take the time you spend to create this question to read the stacktrace (it says where to find the null pointer) and than spend the rest of the time to debug (if it is more complex than the simple null pointer). But a plus point for the quality of your question. Everything is there... code, log, pictures :)
Change:
textThatWillTakeTheHitText.setText(i);
to:
textThatWillTakeTheHitText.setText(String.valueOf(i));
Make sure that this line:
buttonThatWillTakeYouPlacesButton = (Button)findViewById(R.id.buttonThatWillGiveThyPowerButton);
Actually returns something and not just null.
I am creating an application that checks the installation of a package and then launches the market-place with its id.
When I try to launch market place with id of an application say com.mybrowser.android by throwing an intent android.intent.action.VIEW with url: market://details?id=com.mybrowser.android, the market place application does launches but crashes after launch.
Note: the application com.mybrowser.android doesn't exists in the market-place.
MyApplication is my application.
$ adb logcat
I/ActivityManager( 1030): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=myapp.testapp/.MyApplication }
I/ActivityManager( 1030): Start proc myapp.testapp for activity myapp.testapp/.MyApplication: pid=3858 uid=10047 gids={1015, 3003}
I/MyApplication( 3858): [ Activity CREATED ]
I/MyApplication( 3858): [ Activity STARTED ]
I/MyApplication( 3858): onResume
D/dalvikvm( 1109): GC freed 6571 objects / 423480 bytes in 73ms
I/MyApplication( 3858): Pressed OK button
I/MyApplication( 3858): Broadcasting Intent: android.intent.action.VIEW, data: market://details?id=com.mybrowser.android
I/ActivityManager( 1030): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.mybrowser.android flg=0x10000000 cmp=com.android.ven
ding/.AssetInfoActivity }
I/MyApplication( 3858): onPause
I/ActivityManager( 1030): Start proc com.android.vending for activity com.android.vending/.AssetInfoActivity: pid=3865 uid=10023 gids={3003}
I/ActivityThread( 3865): Publishing provider com.android.vending.SuggestionsProvider: com.android.vending.SuggestionsProvider
D/dalvikvm( 1030): GREF has increased to 701
I/vending ( 3865): com.android.vending.api.RadioHttpClient$1.handleMessage(): Handle DATA_STATE_CHANGED event: NetworkInfo: type: WIFI[], state: CONNECTED/CO
NNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true
I/ActivityManager( 1030): Displayed activity com.android.vending/.AssetInfoActivity: 609 ms (total 7678 ms)
D/dalvikvm( 1030): GC freed 10458 objects / 676440 bytes in 128ms
I/MyApplication( 3858): [ Activity STOPPED ]
D/dalvikvm( 3865): GC freed 3538 objects / 254008 bytes in 84ms
W/dalvikvm( 3865): threadid=19: thread exiting with uncaught exception (group=0x4001b180)
E/AndroidRuntime( 3865): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
E/AndroidRuntime( 3865): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime( 3865): at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime( 3865): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
E/AndroidRuntime( 3865): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
E/AndroidRuntime( 3865): at java.lang.Thread.run(Thread.java:1096)
E/AndroidRuntime( 3865): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 3865): at com.android.vending.AssetItemAdapter$ReloadLocalAssetInformationTask.doInBackground(AssetItemAdapter.java:845)
E/AndroidRuntime( 3865): at com.android.vending.AssetItemAdapter$ReloadLocalAssetInformationTask.doInBackground(AssetItemAdapter.java:831)
E/AndroidRuntime( 3865): at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime( 3865): ... 4 more
I/Process ( 1030): Sending signal. PID: 3865 SIG: 3
I/dalvikvm( 3865): threadid=7: reacting to signal 3
I/dalvikvm( 3865): Wrote stack trace to '/data/anr/traces.txt'
I/DumpStateReceiver( 1030): Added state dump to 1 crashes
D/AndroidRuntime( 3865): Shutting down VM
W/dalvikvm( 3865): threadid=3: thread exiting with uncaught exception (group=0x4001b180)
E/AndroidRuntime( 3865): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3865): java.lang.NullPointerException
E/AndroidRuntime( 3865): at com.android.vending.controller.AssetInfoActivityController.getIdDeferToLocal(AssetInfoActivityController.java:637)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity.displayAssetInfo(AssetInfoActivity.java:556)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity.access$800(AssetInfoActivity.java:74)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity$LoadAssetInfoAction$1.run(AssetInfoActivity.java:917)
E/AndroidRuntime( 3865): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 3865): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3865): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3865): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 3865): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3865): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3865): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 3865): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 3865): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 1030): Sending signal. PID: 3865 SIG: 3
W/ActivityManager( 1030): Process com.android.vending has crashed too many times: killing!
D/ActivityManager( 1030): Force finishing activity com.android.vending/.AssetInfoActivity
I/dalvikvm( 3865): threadid=7: reacting to signal 3
D/ActivityManager( 1030): Force removing process ProcessRecord{44e48548 3865:com.android.vending/10023} (com.android.vending/10023)
However, when I try to launch the market place for a package that exists in the market place say com.opera.mini.android, everything works. Log for this case:
D/dalvikvm( 966): GC freed 2781 objects / 195056 bytes in 99ms
I/MyApplication( 1165): Pressed OK button
I/MyApplication( 1165): Broadcasting Intent: android.intent.action.VIEW, data: market://details?id=com.opera.mini.android
I/ActivityManager( 78): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.opera.mini.android flg=0x10000000 cmp=com.android.vending/.AssetInfoActivity }
I/AndroidRuntime( 1165): AndroidRuntime onExit calling exit(0)
I/WindowManager( 78): WIN DEATH: Window{44c72308 myapp.testapp/myapp.testapp.MyApplication paused=true}
I/ActivityManager( 78): Process myapp.testapp (pid 1165) has died.
I/WindowManager( 78): WIN DEATH: Window{44c72958 myapp.testapp/myapp.testapp.MyApplication paused=false}
D/dalvikvm( 78): GC freed 31778 objects / 1796368 bytes in 142ms
I/ActivityManager( 78): Displayed activity com.android.vending/.AssetInfoActivity: 214 ms (total 22866 ms)
W/KeyCharacterMap( 978): No keyboard for id 65540
W/KeyCharacterMap( 978): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
V/RenderScript_jni( 966): surfaceCreated
V/RenderScript_jni( 966): surfaceChanged
V/RenderScript( 966): setSurface 480 762 0x573430
D/ViewFlipper( 966): updateRunning() mVisible=true, mStarted=true, mUserPresent=true, mRunning=true
D/dalvikvm( 978): GC freed 10065 objects / 624440 bytes in 95ms
Any ideas?
I am having similar problem when trying to open a detail page in Market app using "market://details?id=pname:org.rabold.android.puzzleblox" URL from an application.
I can create a shortcut using AnyCut like this:
action: android.intent.action.VIEW
data: market://details?id=pname:org.rabold.android.puzzleblox
type:
then it works fine.
However, if I create an Android application with a button to launch Market with the same Uri as above, then I get an error in Market app like this: "Attention: A server error has occurred. Retry, or cancel and return to the previous screen."
The code of my button's listener looks like this:
okButton = (Button) findViewById(R.id.okButton);
okButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=pname:org.rabold.android.puzzleblox"));
//Uri.parse("market://search?q=pname:org.rabold.android.puzzleblox"));
startActivity(intent);
}
});
Note in the above code, if I use 'search' instead of 'details' then it works. I'd like to use 'details' instead of 'search' because I know that my app will be available on Market when it's done. Thanks.
Update!:
Do not use "pname:"
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);
Works perfectly.
per:
http://developer.android.com/distribute/googleplay/promote/linking.html#android-app
☮ ♥ ☺
thnx Daniel, I can confirm that your solution is working fine on device.
#TPham: please try with correct url (append id only),
passing correct id also working fine, see example below;
static final String APP_MARKET_URL = "market://details?id=com.wareninja.android.fotolicke";
Intent intent = new Intent( Intent.ACTION_VIEW,
Uri.parse(APP_MARKET_URL));
startActivity(intent);
instead of launching with the exact ID, you can try doing it by searching by the package.
Intent intent = new Intent( Intent.ACTION_VIEW,
Uri.parse("market://search?q=pname:com.package.package2.package3"));
startActivity(intent);