I have an app where users can click on certain buttons in my app and it will launch specific settings page from Android to the user. I uses the android API from their website http://developer.android.com/reference/android/provider/Settings.html
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
currentContext.startActivity(intent);
Intent intent = new Intent(Settings.ACTION_DISPLAY_SETTINGS);
currentContext.startActivity(intent);
These are some of the settings pages that my app will open. So far I have no problem launching these two intents from my app. However, when I try to launch the "About tablet" page with the code below, the Settings process crashes.
Intent intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
currentContext.startActivity(intent);
It crashes on android 4.1.1 but it works fine on android 3.2. I'm still new to Android and I am at a lost on why it crashes. I'm new to StackOverflow as well. Hopefully I am able to get some answers here and nice to meet you all.
Here's my logcat:
09-19 09:50:12.830: I/ActivityManager(270): START {act=android.settings.DEVICE_INFO_SETTINGS cmp=com.android.settings/.Settings$DeviceInfoSettingsActivity u=0} from pid 1627
09-19 09:50:12.910: D/dalvikvm(270): GC_FOR_ALLOC freed 738K, 13% free 11824K/13575K, paused 62ms, total 62ms
09-19 09:50:13.010: W/System.err(1675): Removed 2131231183
09-19 09:50:13.020: W/System.err(1675): Removed 2131231190
09-19 09:50:13.060: D/LocalBluetoothProfileManager(1675): LocalBluetoothProfileManager construction complete
09-19 09:50:13.060: D/AndroidRuntime(1675): Shutting down VM
09-19 09:50:13.060: W/dalvikvm(1675): threadid=1: thread exiting with uncaught exception (group=0x40d4c300)
09-19 09:50:13.060: E/AndroidRuntime(1675): FATAL EXCEPTION: main
09-19 09:50:13.060: E/AndroidRuntime(1675): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.Settings$DeviceInfoSettingsActivity}: java.lang.NullPointerException
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.os.Handler.dispatchMessage(Handler.java:99)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.os.Looper.loop(Looper.java:137)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-19 09:50:13.060: E/AndroidRuntime(1675): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 09:50:13.060: E/AndroidRuntime(1675): at java.lang.reflect.Method.invoke(Method.java:511)
09-19 09:50:13.060: E/AndroidRuntime(1675): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-19 09:50:13.060: E/AndroidRuntime(1675): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 09:50:13.060: E/AndroidRuntime(1675): at dalvik.system.NativeStart.main(Native Method)
09-19 09:50:13.060: E/AndroidRuntime(1675): Caused by: java.lang.NullPointerException
09-19 09:50:13.060: E/AndroidRuntime(1675): at com.android.settings.Settings.onCreate(Settings.java:167)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.app.Activity.performCreate(Activity.java:5008)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
09-19 09:50:13.060: E/AndroidRuntime(1675): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-19 09:50:13.060: E/AndroidRuntime(1675): ... 11 more
09-19 09:50:13.090: W/ActivityManager(270): Force finishing activity com.android.settings/.Settings$DeviceInfoSettingsActivity
09-19 09:50:13.090: W/ActivityManager(270): Force finishing activity com.panasonic.tbexperience/.view.templates.TwoColumnsControlActivity
09-19 09:50:13.100: W/InputMethodManagerService(270): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#41811de8 attribute=null
09-19 09:50:13.130: D/dalvikvm(1675): GC_CONCURRENT freed 187K, 4% free 6233K/6471K, paused 12ms+5ms, total 60ms
09-19 09:50:13.610: W/ActivityManager(270): Activity pause timeout for ActivityRecord{417ea2e0 com.android.settings/.Settings$DeviceInfoSettingsActivity}
09-19 09:50:13.820: D/dalvikvm(445): GC_FOR_ALLOC freed 1020K, 33% free 14790K/22023K, paused 41ms, total 41ms
09-19 09:50:13.960: D/dalvikvm(445): GC_FOR_ALLOC freed 1057K, 30% free 15633K/22023K, paused 39ms, total 39ms
09-19 09:50:14.010: D/dalvikvm(445): GC_FOR_ALLOC freed 362K, 24% free 16871K/22023K, paused 32ms, total 32ms
09-19 09:50:14.060: D/dalvikvm(445): GC_CONCURRENT freed 1289K, 20% free 17622K/22023K, paused 3ms+7ms, total 39ms
09-19 09:50:14.060: D/dalvikvm(445): WAIT_FOR_CONCURRENT_GC blocked 29ms
09-19 09:50:14.060: D/dalvikvm(445): WAIT_FOR_CONCURRENT_GC blocked 17ms
09-19 09:50:14.100: D/dalvikvm(445): GC_FOR_ALLOC freed 1693K, 25% free 16723K/22023K, paused 31ms, total 31ms
09-19 09:50:14.190: D/dalvikvm(445): GC_CONCURRENT freed 1126K, 21% free 17585K/22023K, paused 14ms+9ms, total 64ms
09-19 09:50:14.190: D/dalvikvm(445): WAIT_FOR_CONCURRENT_GC blocked 50ms
09-19 09:50:14.390: I/dalvikvm(270): Jit: resizing JitTable from 8192 to 16384
09-19 09:50:16.870: I/Process(1675): Sending signal. PID: 1675 SIG: 9
09-19 09:50:16.890: I/ActivityManager(270): Process com.android.settings (pid 1675) has died.
09-19 09:50:16.890: W/ActivityManager(270): Force removing ActivityRecord{4166f668 com.android.settings/.Settings$DeviceInfoSettingsActivity}: app died, no saved state
09-19 09:50:16.890: W/InputMethodManagerService(270): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#415f2878 attribute=null
09-19 09:50:32.250: D/dalvikvm(1552): GC_CONCURRENT freed 424K, 9% free 6942K/7559K, paused 12ms+3ms, total 39ms
Also, I tried to directly set the classname for this api...
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.Settings$DeviceInfoSettingsActivity");
currentContext.startActivity(intent);
Same thing happens.It works for android 3.2 but doesn't work in 4.1.1. I've got a feeling that maybe I did not get the right class name for the 4.1.1 version. Does anyone know the direct class name to open the "About Tablet" page or whether is it possible to open that page programmatically?
Regards,
shuwen
android api doc say:
In some cases, a matching Activity may not exist, so ensure you safeguard against this.
so you should check this intent or catch this exception yourself.
Related
I've been trying to turn on an Accessibility Service using Android's. I run an emulator using Android Studio (Nexus S API 19, armabi-v7). I'm able to open the accessibility settings when the emulator is running. (By clicking on the circled submenu)
Setting Screen with Accessibility Sub-Menu highlighted
Yet when I run try to attach monkeyrunner by opening an interactive monkeyrunner terminal and running:
>> from android.com.monkeyrunner import MonkeyRunner, MonkeyDevice
>> d = MonkeyRunner.waitForConnection()
I'm unable to get navigate to the accessibility settings screen and get the error message
Result of selecting accessibility sub-menu from settings when MonkeyDevice is attached
as soon as I detach the monkeyDevice, I'm able to get to the accessibility settings screen again. Any idea what could cause it?
snippet from the logs when there's an error:
##Logs from Failure ## I/ActivityManager( 357): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.settings/.Settings} from pid 519 ... I/ActivityManager( 357): START u0 {act=android.intent.action.MAIN cmp=com.android.settings/.SubSettings (has extras)} from pid 751
...
D/SubSettings( 751): Launching fragment com.android.settings.accessibility.AccessibilitySettings ... E/AndroidRuntime( 751): FATAL EXCEPTION: main
E/AndroidRuntime( 751): Process: com.android.settings, PID: 751
E/AndroidRuntime( 751): java.lang.RuntimeException: Unable to resume activity {com.android.settings/com.android.settings.SubSettings}: java.lang.NullPointerException
E/AndroidRuntime( 751): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2774)
E/AndroidRuntime( 751): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2803)
E/AndroidRuntime( 751): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2238)
E/AndroidRuntime( 751): at android.app.ActivityThread.access$800(ActivityThread.java:135)
E/AndroidRuntime( 751): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
E/AndroidRuntime( 751): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 751): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 751): at android.app.ActivityThread.main(ActivityThread.java:5001)
E/AndroidRuntime( 751): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 751): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 751): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
E/AndroidRuntime( 751): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
E/AndroidRuntime( 751): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 751): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 751): at com.android.settings.accessibility.AccessibilitySettings.loadInstalledServices(AccessibilitySettings.java:641)
E/AndroidRuntime( 751): at com.android.settings.accessibility.AccessibilitySettings.onResume(AccessibilitySettings.java:214)
E/AndroidRuntime( 751): at android.app.Fragment.performResume(Fragment.java:1743)
E/AndroidRuntime( 751): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:924)
E/AndroidRuntime( 751): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
E/AndroidRuntime( 751): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1044)
E/AndroidRuntime( 751): at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1863)
E/AndroidRuntime( 751): at android.app.Activity.performResume(Activity.java:5320)
E/AndroidRuntime( 751): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2764)
E/AndroidRuntime( 751): ... 12 more
W/ActivityManager( 357): Force finishing activity com.android.settings/.SubSettings
W/ActivityManager( 357): Force finishing activity com.android.settings/.Settings ... W/ActivityManager( 357): Activity pause timeout for ActivityRecord{b3ea9e08 u0 com.android.settings/.SubSettings t2 f}
There seems to be a NullPointer exception, but I don't know what could cause that
##Log Snippet Without Failure I/ActivityManager( 357): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.settings/.Settings} from pid 519
I/ActivityManager( 357): Start proc com.android.settings for activity com.android.settings/.Settings: pid=1095 uid=1000 gids={41000, 1028, 1015, 3002, 3001, 3003}
D/dalvikvm( 59): GC_EXPLICIT freed 40K, 5% free 2777K/2900K, paused 15ms+3ms, total 96ms
D/dalvikvm( 59): GC_EXPLICIT freed <1K, 5% free 2777K/2900K, paused 3ms+14ms, total 67ms
D/dalvikvm( 59): GC_EXPLICIT freed <1K, 5% free 2777K/2900K, paused 7ms+14ms, total 76ms
D/dalvikvm( 1095): GC_FOR_ALLOC freed 118K, 7% free 2987K/3188K, paused 35ms, total 37ms
I/dalvikvm-heap( 1095): Grow heap (frag case) to 3.602MB for 635812-byte allocation
D/dalvikvm( 1095): GC_FOR_ALLOC freed 3K, 6% free 3605K/3812K, paused 44ms, total 44ms
D/dalvikvm( 1095): GC_CONCURRENT freed <1K, 6% free 3605K/3812K, paused 4ms+2ms, total 53ms
E/BluetoothAdapter( 1095): Bluetooth binder is null
D/dalvikvm( 1095): GC_CONCURRENT freed 209K, 8% free 3793K/4088K, paused 2ms+16ms, total 65ms
D/ ( 1095): HostConnection::get() New Host Connection established 0xb82ef4c0, tid 1095
W/EGL_emulation( 1095): eglSurfaceAttrib not implemented
D/OpenGLRenderer( 1095): Enabling debug mode 0
I/ActivityManager( 357): Displayed com.android.settings/.Settings:
+2s599ms
D/dalvikvm( 1095): GC_CONCURRENT freed 124K, 5% free 4057K/4268K, paused 15ms+5ms, total 101ms
I/ActivityManager( 357): START u0 {act=android.intent.action.MAIN cmp=com.android.settings/.SubSettings (has extras)} from pid 1095
D/SubSettings( 1095): Launching fragment com.android.settings.accessibility.AccessibilitySettings
W/EGL_emulation( 1095): eglSurfaceAttrib not implemented
D/dalvikvm( 1095): GC_CONCURRENT freed 223K, 7% free 4267K/4576K, paused 20ms+65ms, total 345ms
I/Choreographer( 1095): Skipped 120 frames! The application may be doing too much work on its main thread.
I/ActivityManager( 357): Displayed com.android.settings/.SubSettings:
+3s235ms
Getting this error, no matter which genymotion virtual device I choose:
dlopen("/data/app-lib/com.brainlogin.facedetectlib-1/libjniavutil.so") failed: dlopen failed: library "/system/lib/libhoudini.so" not found
I'm initiating javacv statically (I have all the .so files in my lib folder).
My code to load the libraries
System.loadLibrary("detection_based_tracker");
I've also tried manually trigger loading libopencv_java based on other posts:
System.loadLibrary("libopencv_java");
System.loadLibrary("detection_based_tracker");
Note that the same app runs fine on Eclipse's ADT emulators and on physical devices.
Also note that my other apps not having javacv run fine on the Genymotion virtual devices.
Here is the full logcat:
02-21 11:33:49.177: D/AndroidRuntime(1673): CheckJNI is OFF
02-21 11:33:49.185: D/dalvikvm(1673): Trying to load lib libjavacore.so 0x0
02-21 11:33:49.185: D/dalvikvm(1673): Added shared lib libjavacore.so 0x0
02-21 11:33:49.189: D/dalvikvm(1673): Trying to load lib libnativehelper.so 0x0
02-21 11:33:49.189: D/dalvikvm(1673): Added shared lib libnativehelper.so 0x0
02-21 11:33:49.189: D/dalvikvm(1673): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
02-21 11:33:49.201: D/dalvikvm(1673): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
02-21 11:33:49.241: E/memtrack(1673): Couldn't load memtrack module (No such file or directory)
02-21 11:33:49.241: E/android.os.Debug(1673): failed to load memtrack module: -2
02-21 11:33:49.265: D/AndroidRuntime(1673): Calling main entry com.android.commands.am.Am
02-21 11:33:49.273: I/ActivityManager(540): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.brainlogin.facedetectlib/.FaceDetect} from pid 1673
02-21 11:33:49.281: D/(540): HostConnection::get() New Host Connection established 0xb8ba2cf8, tid 552
02-21 11:33:49.509: D/dalvikvm(540): GC_FOR_ALLOC freed 340K, 51% free 6547K/13196K, paused 7ms, total 7ms
02-21 11:33:49.509: I/dalvikvm-heap(540): Grow heap (frag case) to 7.285MB for 856092-byte allocation
02-21 11:33:49.521: D/dalvikvm(540): GC_FOR_ALLOC freed 3K, 48% free 7380K/14036K, paused 14ms, total 14ms
02-21 11:33:49.529: D/dalvikvm(540): GC_FOR_ALLOC freed 2K, 48% free 7384K/14036K, paused 7ms, total 7ms
02-21 11:33:49.533: I/dalvikvm-heap(540): Grow heap (frag case) to 8.103MB for 856092-byte allocation
02-21 11:33:49.541: D/dalvikvm(540): GC_FOR_ALLOC freed <1K, 45% free 8220K/14876K, paused 8ms, total 8ms
02-21 11:33:49.557: D/AndroidRuntime(1673): Shutting down VM
02-21 11:33:49.557: D/jdwp(1673): Got wake-up signal, bailing out of select
02-21 11:33:49.557: D/dalvikvm(1673): Debugger has detached; object registry had 1 entries
02-21 11:33:49.565: D/dalvikvm(1686): Late-enabling CheckJNI
02-21 11:33:49.569: I/ActivityManager(540): Start proc com.brainlogin.facedetectlib for activity com.brainlogin.facedetectlib/.FaceDetect: pid=1686 uid=10058 gids={50058, 1028, 1015}
02-21 11:33:49.569: D/MobileDataStateTracker(540): default: setPolicyDataEnable(enabled=true)
02-21 11:33:49.589: D/(540): HostConnection::get() New Host Connection established 0xb8ba2ec8, tid 554
02-21 11:33:49.589: D/dalvikvm(1686): Debugger has detached; object registry had 1 entries
02-21 11:33:49.661: D/MobileDataStateTracker(540): default: setPolicyDataEnable(enabled=true)
02-21 11:33:49.737: D/debug(1686): copy SUCCESS for flandmark_model.dat
02-21 11:33:49.745: D/CameraBridge(1686): Attr count: 3
02-21 11:33:49.777: D/dalvikvm(1686): GC_CONCURRENT freed 124K, 6% free 3502K/3692K, paused 3ms+1ms, total 17ms
02-21 11:33:49.789: D/dalvikvm(1686): GC_CONCURRENT freed 192K, 7% free 3819K/4088K, paused 0ms+1ms, total 5ms
02-21 11:33:49.789: D/dalvikvm(1686): WAIT_FOR_CONCURRENT_GC blocked 3ms
02-21 11:33:49.801: D/dalvikvm(1686): GC_CONCURRENT freed 281K, 11% free 3935K/4404K, paused 2ms+0ms, total 4ms
02-21 11:33:49.801: D/dalvikvm(1686): WAIT_FOR_CONCURRENT_GC blocked 3ms
02-21 11:33:49.809: D/dalvikvm(1686): GC_FOR_ALLOC freed 255K, 11% free 3994K/4480K, paused 6ms, total 7ms
02-21 11:33:49.825: D/dalvikvm(1686): GC_CONCURRENT freed 283K, 8% free 4193K/4556K, paused 1ms+2ms, total 8ms
02-21 11:33:49.841: D/dalvikvm(1686): GC_CONCURRENT freed 229K, 7% free 4451K/4756K, paused 0ms+2ms, total 8ms
02-21 11:33:49.869: D/dalvikvm(1686): GC_CONCURRENT freed 257K, 7% free 4675K/5008K, paused 6ms+1ms, total 15ms
02-21 11:33:49.885: D/dalvikvm(1686): No JNI_OnLoad found in /system/lib/libc.so 0xa4fd7c78, skipping init
02-21 11:33:49.885: D/dalvikvm(1686): No JNI_OnLoad found in /system/lib/libm.so 0xa4fd7c78, skipping init
02-21 11:33:49.889: D/dalvikvm(1686): No JNI_OnLoad found in /system/lib/libz.so 0xa4fd7c78, skipping init
02-21 11:33:49.893: D/dalvikvm(1686): No JNI_OnLoad found in /system/lib/libdl.so 0xa4fd7c78, skipping init
02-21 11:33:49.893: D/dalvikvm(1686): No JNI_OnLoad found in /system/lib/liblog.so 0xa4fd7c78, skipping init
02-21 11:33:49.893: D/dalvikvm(1686): Trying to load lib /data/app-lib/com.brainlogin.facedetectlib-1/libavutil.so 0xa4fd7c78
02-21 11:33:49.897: D/dalvikvm(1686): Added shared lib /data/app-lib/com.brainlogin.facedetectlib-1/libavutil.so 0xa4fd7c78
02-21 11:33:49.897: D/dalvikvm(1686): No JNI_OnLoad found in /data/app-lib/com.brainlogin.facedetectlib-1/libavutil.so 0xa4fd7c78, skipping init
02-21 11:33:49.897: D/dalvikvm(1686): Trying to load lib /data/app-lib/com.brainlogin.facedetectlib-1/libjniavutil.so 0xa4fd7c78
02-21 11:33:49.901: E/dalvikvm(1686): dlopen("/data/app-lib/com.brainlogin.facedetectlib-1/libjniavutil.so") failed: dlopen failed: library "/system/lib/libhoudini.so" not found
02-21 11:33:49.901: W/dalvikvm(1686): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/bytedeco/javacpp/avutil;
02-21 11:33:49.901: D/dalvikvm(1686): GC_CONCURRENT freed 453K, 11% free 4679K/5208K, paused 1ms+2ms, total 14ms
02-21 11:33:49.905: I/dalvikvm(1686): Rejecting re-init on previously-failed class Lorg/bytedeco/javacpp/avutil; v=0x0
02-21 11:33:49.905: W/dalvikvm(1686): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lorg/bytedeco/javacpp/avcodec$AVPacket;
02-21 11:33:49.905: D/AndroidRuntime(1686): Shutting down VM
02-21 11:33:49.905: W/dalvikvm(1686): threadid=1: thread exiting with uncaught exception (group=0xa4cb5b20)
02-21 11:33:49.905: E/AndroidRuntime(1686): FATAL EXCEPTION: main
I am creating an app on Android, which involves an Activity and a service. One of the components of the service is meant to send a signal to the MainActivity, which will execute some specific code. The problem is, trying to send the intent makes the app crash.
Here is the code that sends the intent. Note that it resides in the inside of a doInBackground function of an AsyncTask object, which resides inside the said service:
#Override
protected String doInBackground(Socket... client) {
Intent received = new Intent();
received.setAction("com.mycompany.Messenger.MESSAGE_RECEIVED");
sendBroadcast(received);
}
Note that if I comment out sendBroadcast(received), the app does not crash.
Here is the handler of the Intent inside MainActivity (which has the name ChatBubbleActivity in my app):
public class MessageReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(MESSAGE_RECEIVED)) {
String current_message = "Intent works!";
TextView textView = (TextView) findViewById(R.id.myText);
textView.setText(current_message);
}
}
}
And this is the declaration of the Receiver in manifest:
<receiver android:name=".ChatBubbleActivity$MessageReceiver">
<intent-filter>
<action android:name="com.mycompany.Messenger.MESSAGE_RECEIVED"/>
</intent-filter>
</receiver>
, inside the <activity> chunk.
What is it that I might be missing?
EDIT:New version of code based on answers, still crashing.
EDIT logcat:
02-04 16:17:32.444 487-489/? D/dalvikvm﹕ GC_CONCURRENT freed 1662K, 22% free 6885K/8728K, paused 2ms+2ms, total 42ms
02-04 16:17:32.876 1275-1275/? D/AndroidRuntime﹕ >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-04 16:17:32.912 1275-1275/? D/AndroidRuntime﹕ CheckJNI is OFF
02-04 16:17:32.960 1275-1275/? D/dalvikvm﹕ Trying to load lib libjavacore.so 0x0
02-04 16:17:32.964 1275-1275/? D/dalvikvm﹕ Added shared lib libjavacore.so 0x0
02-04 16:17:32.968 1275-1275/? D/dalvikvm﹕ Trying to load lib libnativehelper.so 0x0
02-04 16:17:32.972 1275-1275/? D/dalvikvm﹕ Added shared lib libnativehelper.so 0x0
02-04 16:17:32.972 1275-1275/? D/dalvikvm﹕ No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
02-04 16:17:33.020 1275-1275/? D/dalvikvm﹕ Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
02-04 16:17:33.128 1275-1275/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
02-04 16:17:33.132 1275-1275/? E/android.os.Debug﹕ failed to load memtrack module: -2
02-04 16:17:33.264 1275-1275/? D/AndroidRuntime﹕ Calling main entry com.android.commands.am.Am
02-04 16:17:33.284 487-617/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.mycompany.messenger/com.mycompany.Messenger.ChatBubbleActivity} from pid 1275
02-04 16:17:33.692 1275-1275/? D/AndroidRuntime﹕ Shutting down VM
02-04 16:17:33.692 1275-1279/? D/dalvikvm﹕ GC_CONCURRENT freed 95K, 15% free 576K/676K, paused 1ms+0ms, total 1ms
02-04 16:17:33.884 487-538/? I/ActivityManager﹕ Start proc com.mycompany.messenger for activity com.mycompany.messenger/com.mycompany.Messenger.ChatBubbleActivity: pid=1286 uid=10059 gids={50059, 3003}
02-04 16:17:33.932 1286-1286/? D/dalvikvm﹕ Late-enabling CheckJNI
02-04 16:17:34.228 1286-1286/? D/dalvikvm﹕ GC_FOR_ALLOC freed 60K, 4% free 2873K/2992K, paused 6ms, total 7ms
02-04 16:17:34.236 1286-1286/? I/dalvikvm-heap﹕ Grow heap (frag case) to 3.338MB for 500412-byte allocation
02-04 16:17:34.248 1286-1295/? D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 4% free 3362K/3484K, paused 11ms, total 11ms
02-04 16:17:34.252 1286-1290/? D/dalvikvm﹕ GC_CONCURRENT freed 0K, 4% free 3362K/3484K, paused 1ms+0ms, total 5ms
02-04 16:17:34.696 1286-1286/? D/libEGL﹕ loaded /system/lib/egl/libEGL_genymotion.so
02-04 16:17:34.708 1286-1286/? D/﹕ HostConnection::get() New Host Connection established 0xb7944cb0, tid 1286
02-04 16:17:34.744 1286-1286/? D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_genymotion.so
02-04 16:17:34.744 1286-1286/? D/libEGL﹕ loaded /system/lib/egl/libGLESv2_genymotion.so
02-04 16:17:34.816 1286-1286/? W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
02-04 16:17:34.820 1286-1286/? E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
02-04 16:17:34.824 1286-1286/? E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
02-04 16:17:34.848 1286-1286/? E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
02-04 16:17:34.848 1286-1286/? E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
02-04 16:17:34.852 1286-1286/? D/OpenGLRenderer﹕ Enabling debug mode 0
02-04 16:17:34.932 1286-1300/? W/dalvikvm﹕ threadid=12: thread exiting with uncaught exception (group=0xa4d31b20)
02-04 16:17:34.932 1286-1300/? E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2
Process: com.mycompany.messenger, PID: 1286
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ContextImpl.startActivity(ContextImpl.java:1050)
at android.app.ContextImpl.startActivity(ContextImpl.java:1037)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:311)
at com.mycompany.Messenger.LocalService$DownloadWebpageTask2.doInBackground(LocalService.java:118)
at com.mycompany.Messenger.LocalService$DownloadWebpageTask2.doInBackground(LocalService.java:113)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
02-04 16:17:34.936 487-617/? W/ActivityManager﹕ Force finishing activity com.mycompany.messenger/com.mycompany.Messenger.ChatBubbleActivity
02-04 16:17:35.180 487-840/? W/InputMethodManagerService﹕ Focus gain on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy#529ef2ac (uid=10059 pid=1286)
02-04 16:17:35.288 487-617/? I/WindowManager﹕ Screenshot max retries 4 of Token{52998cec ActivityRecord{5294f214 u0 com.mycompany.messenger/com.mycompany.Messenger.ChatBubbleActivity t4 f}} appWin=Window{52948c58 u0 Starting com.mycompany.messenger} drawState=4
02-04 16:17:35.288 487-617/? W/WindowManager﹕ Screenshot failure taking screenshot for (800x1280) to layer 21015
02-04 16:17:38.512 487-502/? I/Choreographer﹕ Skipped 188 frames! The application may be doing too much work on its main thread.
02-04 16:17:38.516 711-711/? I/Choreographer﹕ Skipped 185 frames! The application may be doing too much work on its main thread.
02-04 16:17:39.708 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:17:40.536 711-711/? W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
02-04 16:17:41.260 487-502/? I/Choreographer﹕ Skipped 35 frames! The application may be doing too much work on its main thread.
02-04 16:17:49.560 1286-1300/? I/Process﹕ Sending signal. PID: 1286 SIG: 9
02-04 16:17:49.580 487-616/? W/InputMethodManagerService﹕ Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#52963b68 attribute=null, token = android.os.BinderProxy#5290713c
02-04 16:17:49.644 487-840/? I/ActivityManager﹕ Process com.mycompany.messenger (pid 1286) has died.
02-04 16:17:49.716 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:17:59.720 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:09.728 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:19.736 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:29.744 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:39.752 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:49.756 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:59.764 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:09.772 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:19.780 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:29.788 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:39.792 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:49.800 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
Do you want to start an activity or send a broadcast? I don't understand your code.
You are starting an activity from a background thread, that's not allowed.
In your AsyncTask, the method protected String doInBackground(Socket... client) is the only one that doesn't run in the UI thread.
When ever you want to start your Broadcast Receiver you don't call it as an acitivty
Your Method
Intent received = new Intent(ChatBubbleActivity.MESSAGE_RECEIVED);
received.putExtra("current", "Intent is working!!");
startActivity(received);
What it should be
Intent intent = new Intent();
intent.setAction("com.tutorialspoint.CUSTOM_INTENT");
sendBroadcast(intent);
Have a look at these tutorials
Vogella
TutorialsPoint
Google Play service to existing projects after adding the library project does not work. As it gives an error.
08-19 12:53:52.863: E/Trace(1977): error opening trace file: No such file or directory (2)
08-19 12:53:52.883: D/dalvikvm(1977): GC_FOR_ALLOC freed 80K, 2% free 10809K/11011K, paused 2ms, total 9ms
08-19 12:53:52.883: I/dalvikvm-heap(1977): Grow heap (frag case) to 12.922MB for 2457612-byte allocation
08-19 12:53:52.895: D/dalvikvm(1977): GC_CONCURRENT freed <1K, 2% free 13209K/13447K, paused 10ms+0ms, total 12ms
08-19 12:53:52.947: D/AndroidRuntime(1977): Shutting down VM
08-19 12:53:52.947: W/dalvikvm(1977): threadid=1: thread exiting with uncaught exception (group=0xa62be288)
08-19 12:53:52.947: E/AndroidRuntime(1977): FATAL EXCEPTION: main
08-19 12:53:52.947: E/AndroidRuntime(1977): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.iloveyou.lovetester/com.iloveyou.lovetester.LoveTestActivity}: android.view.InflateException: Binary XML file line #85: Error inflating class com.google.ads.AdView
08-19 12:53:52.947: E/AndroidRuntime(1977): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-19 12:53:52.947: E/AndroidRuntime(1977): at
I've made a simple Android app that's trying to open a URL (any URL with input will do) on a click of a button.
The code I use is this :
btnTest = (Button)findViewById(R.id.btnTest);
btnTest.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
HelloActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")));
}
});
The problem is that in Android Emulator running Platform 4.0.3, the emulator is crashed everytime I try to input text using soft keyboard into the web. This problem doesn't occur in Emulator running Platform 2.3.3. I've tried many sites and it behaves the same.
Btw, this is the logcat :
02-22 09:35:51.434: I/ActivityManager(81): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.eatmicco.Training/.HelloActivity} from pid 212
02-22 09:35:51.444: D/PermissionCache(36): checking android.permission.READ_FRAME_BUFFER for uid=1000 => granted (623 us)
02-22 09:35:51.704: D/dalvikvm(81): GC_FOR_ALLOC freed 149K, 7% free 11999K/12871K, paused 79ms
02-22 09:35:51.714: I/dalvikvm-heap(81): Grow heap (frag case) to 11.914MB for 129616-byte allocation
02-22 09:35:51.844: D/dalvikvm(81): GC_FOR_ALLOC freed 745K, 13% free 11380K/12999K, paused 68ms
02-22 09:35:51.913: D/dalvikvm(478): Not late-enabling CheckJNI (already on)
02-22 09:35:51.944: I/ActivityManager(81): Start proc com.eatmicco.Training for activity com.eatmicco.Training/.HelloActivity: pid=478 uid=10048 gids={1015}
02-22 09:35:51.954: D/(81): HostConnection::get() New Host Connection established 0xbdd28, tid 123
02-22 09:35:52.094: W/NetworkManagementSocketTagger(81): setKernelCountSet(10048, 1) failed with errno -2
02-22 09:35:52.124: D/OpenGLRenderer(212): Flushing caches (mode 1)
02-22 09:35:52.334: V/PhoneStatusBar(151): setLightsOn(true)
02-22 09:35:52.533: W/InputManagerService(81): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy#415554e8 (uid=10013 pid=212)
02-22 09:35:52.533: D/(478): HostConnection::get() New Host Connection established 0x15c708, tid 478
02-22 09:35:52.593: D/OpenGLRenderer(212): Flushing caches (mode 0)
02-22 09:35:52.704: I/Process(81): Sending signal. PID: 478 SIG: 3
02-22 09:35:52.704: I/dalvikvm(478): threadid=3: reacting to signal 3
02-22 09:35:52.714: I/dalvikvm(478): Wrote stack traces to '/data/anr/traces.txt'
02-22 09:35:53.004: I/ActivityManager(81): Displayed com.eatmicco.Training/.HelloActivity: +1s114ms
02-22 09:35:53.154: W/NetworkManagementSocketTagger(81): setKernelCountSet(10013, 0) failed with errno -2
02-22 09:35:54.204: I/ActivityManager(81): START {act=android.intent.action.VIEW dat=http://www.google.com cmp=com.android.browser/.BrowserActivity} from pid 478
02-22 09:35:54.573: I/ActivityManager(81): Start proc com.android.browser for activity com.android.browser/.BrowserActivity: pid=491 uid=10002 gids={3003, 1015}
02-22 09:35:54.673: W/NetworkManagementSocketTagger(81): setKernelCountSet(10002, 1) failed with errno -2
02-22 09:35:54.933: I/ActivityThread(491): Pub com.android.browser;browser: com.android.browser.provider.BrowserProvider2
02-22 09:35:54.984: I/ActivityThread(491): Pub com.android.browser.home: com.android.browser.homepages.HomeProvider
02-22 09:35:54.984: I/ActivityThread(491): Pub com.android.browser.snapshots: com.android.browser.provider.SnapshotProvider
02-22 09:35:55.193: I/Process(81): Sending signal. PID: 491 SIG: 3
02-22 09:35:55.193: I/dalvikvm(491): threadid=3: reacting to signal 3
02-22 09:35:55.303: I/dalvikvm(491): Wrote stack traces to '/data/anr/traces.txt'
02-22 09:35:55.553: D/dalvikvm(491): GC_CONCURRENT freed 257K, 4% free 9281K/9607K, paused 8ms+4ms
02-22 09:35:55.603: E/ActivityThread(491): Failed to find provider info for com.google.settings
02-22 09:35:55.603: E/ActivityThread(491): Failed to find provider info for com.google.settings
02-22 09:35:55.693: I/Process(81): Sending signal. PID: 491 SIG: 3
02-22 09:35:55.693: I/dalvikvm(491): threadid=3: reacting to signal 3
02-22 09:35:55.813: I/dalvikvm(491): Wrote stack traces to '/data/anr/traces.txt'
02-22 09:35:55.893: D/dalvikvm(491): GC_FOR_ALLOC freed 191K, 4% free 9475K/9799K, paused 34ms
02-22 09:35:55.943: D/dalvikvm(491): GC_FOR_ALLOC freed 5K, 4% free 9647K/9991K, paused 31ms
02-22 09:35:55.993: D/dalvikvm(491): GC_FOR_ALLOC freed <1K, 4% free 9818K/10183K, paused 42ms
02-22 09:35:56.023: D/dalvikvm(491): GC_FOR_ALLOC freed <1K, 4% free 9989K/10375K, paused 35ms
02-22 09:35:56.073: D/dalvikvm(491): GC_FOR_ALLOC freed 1K, 4% free 10162K/10567K, paused 32ms
02-22 09:35:56.114: D/dalvikvm(491): GC_FOR_ALLOC freed <1K, 3% free 10504K/10759K, paused 33ms
02-22 09:35:56.163: E/libEGL(491): call to OpenGL ES API with no current context (logged once per thread)
02-22 09:35:56.183: D/ShaderProgram(491): couldn't load the vertex shader!
02-22 09:35:56.183: E/libEGL(491): call to OpenGL ES API with no current context (logged once per thread)
02-22 09:35:56.183: D/ShaderProgram(491): couldn't load the vertex shader!
02-22 09:35:56.183: E/libEGL(491): call to OpenGL ES API with no current context (logged once per thread)
02-22 09:35:56.183: D/ShaderProgram(491): couldn't load the vertex shader!
02-22 09:35:56.183: E/libEGL(491): call to OpenGL ES API with no current context (logged once per thread)
02-22 09:35:56.183: D/ShaderProgram(491): couldn't load the vertex shader!
02-22 09:35:56.183: E/libEGL(491): call to OpenGL ES API with no current context (logged once per thread)
02-22 09:35:56.183: D/ShaderProgram(491): couldn't load the vertex shader!
02-22 09:35:56.193: I/Process(81): Sending signal. PID: 491 SIG: 3
02-22 09:35:56.193: I/dalvikvm(491): threadid=3: reacting to signal 3
02-22 09:35:56.233: I/dalvikvm(491): Wrote stack traces to '/data/anr/traces.txt'
02-22 09:35:56.383: D/dalvikvm(491): GC_FOR_ALLOC freed 20K, 3% free 10896K/11143K, paused 57ms
02-22 09:35:56.393: D/WebViewTimersControl(491): onBrowserActivityResume
02-22 09:35:56.393: D/WebViewTimersControl(491): Resuming webview timers, view=com.android.browser.BrowserWebView#41313558
02-22 09:35:56.403: W/BaseUi(491): mMainView is already attached to wrapper in attachTabToContentView!
02-22 09:35:56.413: W/BaseUi(491): mContainer is already attached to content in attachTabToContentView!
02-22 09:35:56.433: V/NFC(491): this device does not have NFC support
02-22 09:35:56.543: D/libEGL(491): loaded /system/lib/egl/libGLES_android.so
02-22 09:35:56.593: D/libEGL(491): loaded /system/lib/egl/libEGL_emulation.so
02-22 09:35:56.593: D/(491): HostConnection::get() New Host Connection established 0x1ec618, tid 491
02-22 09:35:56.643: D/libEGL(491): loaded /system/lib/egl/libGLESv1_CM_emulation.so
02-22 09:35:56.643: D/libEGL(491): loaded /system/lib/egl/libGLESv2_emulation.so
02-22 09:35:56.703: I/Process(81): Sending signal. PID: 491 SIG: 3
02-22 09:35:56.703: I/dalvikvm(491): threadid=3: reacting to signal 3
02-22 09:35:56.793: W/EGL_emulation(491): eglSurfaceAttrib not implemented
02-22 09:35:56.823: D/OpenGLRenderer(491): Enabling debug mode 0
02-22 09:35:56.823: I/dalvikvm(491): Wrote stack traces to '/data/anr/traces.txt'
02-22 09:35:57.214: I/Process(81): Sending signal. PID: 491 SIG: 3
02-22 09:35:57.214: I/dalvikvm(491): threadid=3: reacting to signal 3
02-22 09:35:57.273: I/dalvikvm(491): Wrote stack traces to '/data/anr/traces.txt'
02-22 09:35:57.313: I/ActivityManager(81): Displayed com.android.browser/.BrowserActivity: +2s785ms
02-22 09:35:57.733: E/chromium(491): external/chromium/net/disk_cache/backend_impl.cc:1107: [0222/093557:ERROR:backend_impl.cc(1107)] Critical error found -8
02-22 09:35:57.893: D/dalvikvm(491): GC_CONCURRENT freed 65K, 3% free 11348K/11591K, paused 3ms+21ms
02-22 09:35:57.963: D/dalvikvm(491): GC_FOR_ALLOC freed 10K, 3% free 11337K/11591K, paused 60ms
02-22 09:35:57.963: I/dalvikvm-heap(491): Grow heap (frag case) to 11.765MB for 656656-byte allocation
02-22 09:35:57.993: W/chromium(491): external/chromium/net/disk_cache/storage_block-inl.h:119: [0222/093558:WARNING:storage_block-inl.h(119)] Failed data load.
02-22 09:35:57.993: W/chromium(491): external/chromium/net/disk_cache/storage_block-inl.h:119: [0222/093558:WARNING:storage_block-inl.h(119)] Failed data load.
02-22 09:35:58.003: W/chromium(491): external/chromium/net/disk_cache/storage_block-inl.h:119: [0222/093558:WARNING:storage_block-inl.h(119)] Failed data load.
02-22 09:35:58.033: W/chromium(491): external/chromium/net/disk_cache/storage_block-inl.h:119: [0222/093558:WARNING:storage_block-inl.h(119)] Failed data load.
02-22 09:35:58.053: E/chromium(491): external/chromium/net/disk_cache/entry_impl.cc:904: [0222/093558:ERROR:entry_impl.cc(904)] Failed to save user data
02-22 09:35:58.053: E/chromium(491): external/chromium/net/disk_cache/entry_impl.cc:904: [0222/093558:ERROR:entry_impl.cc(904)] Failed to save user data
02-22 09:35:58.143: D/dalvikvm(491): GC_FOR_ALLOC freed 0K, 3% free 11979K/12295K, paused 121ms
02-22 09:35:58.263: W/Tab(491): Failed to save back/forward list for http://www.google.com
02-22 09:35:58.883: W/NetworkManagementSocketTagger(81): setKernelCountSet(10048, 0) failed with errno -2
02-22 09:36:03.363: D/dalvikvm(165): GC_CONCURRENT freed 118K, 3% free 9760K/9991K, paused 4ms+5ms
02-22 09:36:04.403: D/(165): HostConnection::get() New Host Connection established 0x1e7f50, tid 165
02-22 09:36:04.773: D/dalvikvm(165): GC_FOR_ALLOC freed 143K, 3% free 9844K/10119K, paused 224ms
02-22 09:36:04.803: I/dalvikvm-heap(165): Grow heap (frag case) to 10.241MB for 591376-byte allocation
02-22 09:36:04.913: D/dalvikvm(165): GC_FOR_ALLOC freed 9K, 4% free 10412K/10759K, paused 99ms
02-22 09:36:05.053: D/dalvikvm(165): GC_CONCURRENT freed <1K, 4% free 10413K/10759K, paused 3ms+4ms
02-22 09:36:05.623: D/dalvikvm(151): GC_CONCURRENT freed 174K, 29% free 9975K/13959K, paused 4ms+16ms
02-22 09:36:05.803: D/dalvikvm(81): GC_CONCURRENT freed 278K, 12% free 11569K/12999K, paused 5ms+28ms
: E/(): Device disconnected
Can anyone tell me what's wrong here?
Thanks