Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE - android

I am trying to programmatically set the aeroplane mode on.
Settings.System.putInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
Intent aeroPlaneIntent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
aeroPlaneIntent.putExtra("state", true);
context.sendBroadcast(aeroPlaneIntent);
Setting the Global.AIRPLANE_MODE_ON is failing as if I check the status it returns 0 (OFF)
Trying to broadcast the intent it raises the following exception:
03-12 07:01:18.747: E/AndroidRuntime(1579): java.lang.RuntimeException: Unable to start receiver com.example.toggleaeroplanemode.AeroplaneModeReceiver: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=1579, uid=10050
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2431)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.app.ActivityThread.access$1500(ActivityThread.java:141)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.os.Looper.loop(Looper.java:137)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.app.ActivityThread.main(ActivityThread.java:5103)
03-12 07:01:18.747: E/AndroidRuntime(1579): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 07:01:18.747: E/AndroidRuntime(1579): at java.lang.reflect.Method.invoke(Method.java:525)
03-12 07:01:18.747: E/AndroidRuntime(1579): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-12 07:01:18.747: E/AndroidRuntime(1579): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-12 07:01:18.747: E/AndroidRuntime(1579): at dalvik.system.NativeStart.main(Native Method)
03-12 07:01:18.747: E/AndroidRuntime(1579): Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=1579, uid=10050
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.os.Parcel.readException(Parcel.java:1431)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.os.Parcel.readException(Parcel.java:1385)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:2224)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.app.ContextImpl.sendBroadcast(ContextImpl.java:1046)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:344)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:344)
03-12 07:01:18.747: E/AndroidRuntime(1579): at com.example.toggleaeroplanemode.AeroplaneModeReceiver.onReceive(AeroplaneModeReceiver.java:31)
03-12 07:01:18.747: E/AndroidRuntime(1579): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2424)
03-12 07:01:18.747: E/AndroidRuntime(1579): ... 10 more
Is there a way to set the airplane mode ON/OFF?
Please help

For little info:
Use this Permission first..
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
further info: Just check this conversation

The below was tested and verified on Android API 23 & 26 Emulators;
The manifest permission needed is as follows;
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" tools:ignore="ProtectedPermissions"/>
The code is as follows;
boolean turnOnOffAirplaneMode(boolean isTurnOn) {
boolean result = true;
try {
Settings.Global.putInt(context.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, isTurnOn ? 1 : 0);
// The below old code is now not necessary # API Level 23, 26 ...
//Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
//context.sendBroadcast(intent);
} catch (Exception e) {
result = false;
}
return result;
}
The APK should be signed with the relevant platform key for above to work. In the Emulator test, the APK was signed with Google Sign Keys. The keys depend on the OEM of the device.

$ adb shell
$ su
# settings put global airplane_mode_on 0
# am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false

Related

no apps can perform this action in android?

I got message "No apps can perform this action" in my testing phone but in tablet, it work fine. My testing phone is android version 4.2.2 and my tablet is android version 4.4.4. Here is my code.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
String[] mimetypes = {"application/pdf","text/plain","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.wordprocessingml.document"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
startActivityForResult(Intent.createChooser(intent, "Select File"), 3);
If I change in something like that,
startActivityForResult(intent, 3);
I got this errors from my phone, but still fine in tablet.
03-12 09:22:40.015: E/test(10739): Exception
03-12 09:22:40.026: E/AndroidRuntime(10739): FATAL EXCEPTION: main
03-12 09:22:40.026: E/AndroidRuntime(10739): java.lang.IllegalStateException: Could not execute method of the activity
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.view.View$1.onClick(View.java:3688)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.view.View.performClick(View.java:4293)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.view.View$PerformClick.run(View.java:17535)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.os.Handler.handleCallback(Handler.java:725)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.os.Handler.dispatchMessage(Handler.java:92)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.os.Looper.loop(Looper.java:153)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.ActivityThread.main(ActivityThread.java:5299)
03-12 09:22:40.026: E/AndroidRuntime(10739): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:22:40.026: E/AndroidRuntime(10739): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:22:40.026: E/AndroidRuntime(10739): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
03-12 09:22:40.026: E/AndroidRuntime(10739): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
03-12 09:22:40.026: E/AndroidRuntime(10739): at dalvik.system.NativeStart.main(Native Method)
03-12 09:22:40.026: E/AndroidRuntime(10739): Caused by: java.lang.reflect.InvocationTargetException
03-12 09:22:40.026: E/AndroidRuntime(10739): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:22:40.026: E/AndroidRuntime(10739): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.view.View$1.onClick(View.java:3683)
03-12 09:22:40.026: E/AndroidRuntime(10739): ... 11 more
03-12 09:22:40.026: E/AndroidRuntime(10739): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT cat=[android.intent.category.OPENABLE] typ=*/* (has extras) }
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1423)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.internalStartActivityForResult(Activity.java:3427)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.access$200(Activity.java:660)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity$2.onStartActivity(Activity.java:3417)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.startActivityForBusiness(Activity.java:5441)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.startActivityForResult(Activity.java:3413)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.startActivityForResult(Activity.java:3367)
That should work in both device and what should I do.Help me, Please.!!
The Intent Intent.ACTION_OPEN_DOCUMENT is only supported on devices with Android 4.4 (KitKat) and above.
Have a look at the Storage Access Framework docs, and specifically the one on ACTION_OPEN_DOCUMENT.
In Android 4.3 or lower, use ACTION_PICK or ACTION_GET_CONTENT as substitude.
In addition, when you invoke build-in "ACTION", you must verify there is more than one activity to receive it, if not your app may crash. Use the following code snippet to do this:
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
if (isIntentSafe) {
startActivity(intent);
}

populate expandable listview from sqlite database

This is my first time here in this site. I already did searched the web on how to populate sqlite database into expandable listview but i failed.
I follow
these steps on how to create an expandable listview and modify some codes to make it dynamic.
Here is my modified code. This is only to set parent text on expandable listview:
public void setGroupParents() {
String selectQuery = "select * from " + DbHelper.TABLE_NAME + " ORDER BY "+DbHelperTablon.KEY_FNAME+" ASC ";
SQLiteDatabase db = mHelper.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
parentItems.add(cursor.getString(1));
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return;
}
When i tried to run the emulator, the program crashed.
I am a newbie in android development and i need any help from you experts.. Thanks in advance.
Oh.. im sorry. This is the results of my LogCat... This is only the error portion..
03-12 07:25:10.059: ERROR/AndroidRuntime(367): FATAL EXCEPTION: main
03-12 07:25:10.059: ERROR/AndroidRuntime(367): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Sample/com.Sample.MainListview}: java.lang.NullPointerException
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.os.Looper.loop(Looper.java:123)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.main(ActivityThread.java:3647)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at java.lang.reflect.Method.invoke(Method.java:507)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at dalvik.system.NativeStart.main(Native Method)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): Caused by: java.lang.NullPointerException
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at com.Sample.MainListview.setGroupParents(MainListview.java:56)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at com.Sample.MainListview.onCreate(MainListview.java:39)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): ... 11 more
03-12 07:25:12.428: ERROR/InputDispatcher(59): channel '40703be0 com.Sample/com.Sample.Drawer (server)' ~ Consumer closed input channel or an error occurred. events=0x8
03-12 07:25:12.428: ERROR/InputDispatcher(59): channel '40703be0 com.Sample/com.Sample.Drawer (server)' ~ Channel is unrecoverably broken and will be disposed!
well i guess if you initiate the database object outside your class your problem might be solved...

Unfortunately app has stopped error eclipse? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've created an application in eclipse and it was working fine and then suddenly it keeps giving me the error message 'unfortunately app has stopped' could anyone explain where my problem lies from my log cat report as i am new to this and dont really understand what the log cat means?
03-12 12:31:03.465: D/AndroidRuntime(4997): Shutting down VM
03-12 12:31:03.465: W/dalvikvm(4997): threadid=1: thread exiting with uncaught exception (group=0x416a8930)
03-12 12:31:03.465: E/AndroidRuntime(4997): FATAL EXCEPTION: main
03-12 12:31:03.465: E/AndroidRuntime(4997): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softwaresearchapp/com.example.softwaresearchapp.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.os.Looper.loop(Looper.java:137)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-12 12:31:03.465: E/AndroidRuntime(4997): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 12:31:03.465: E/AndroidRuntime(4997): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-12 12:31:03.465: E/AndroidRuntime(4997): at dalvik.system.NativeStart.main(Native Method)
03-12 12:31:03.465: E/AndroidRuntime(4997): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.resolveActivityInfo(ActivityThread.java:1993)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:285)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost.setCurrentTab(TabHost.java:413)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost.addTab(TabHost.java:240)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.example.softwaresearchapp.MainActivity.onCreate(MainActivity.java:27)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Activity.performCreate(Activity.java:5104)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-12 12:31:03.465: E/AndroidRuntime(4997): ... 11 more
03-12 12:31:22.666: I/Process(4997): Sending signal. PID: 4997 SIG: 9`
your logcat clearly said
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Add SoftwareSearchActivity into manifest.xml like
<activity
android:name="com.example.softwaresearchapp.SoftwareSearchActivity"
android:configChanges="keyboardHidden|orientation"
android:label="SoftwareSearch"
/>
Look at this line:
3-12 12:31:03.465: E/AndroidRuntime(4997): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softwaresearchapp/com.example.softwaresearchapp.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Specifically: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Well, have you?
Each activity in your app must be declared in the manifest file. I imagine the minimum information you would want to provide would be the name and label e.g.
<activity
android:name=".SoftwareSearchActivity"
android:label="#string/title_activity_software_search"
/>
You are getting ActivityNotFoundException. Please check for Activity entry for com.example.softwaresearchapp.SoftwareSearchActivity in manifest file.

javacv for android

I'm trying to use OpenCV on android
I created my android project, added javacv.jar and iavacpp.jar to the build path, created the lib folder and copied the *.so files from javacv-arm.jar to libs/armeabi.
All jar & *.so files are version 2.4.2.
When I run the app, I created a test button. When it is clicked I'm calling this line:
IplImage image = cvLoadImage("file:///android_asset//"+"pic1.jpg");
and get the following crash
03-12 19:22:12.189: E/AndroidRuntime(4524): FATAL EXCEPTION: main
03-12 19:22:12.189: E/AndroidRuntime(4524): java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.myapp.MainActivity.runTest(MainActivity.java:260)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.myapp.MainActivity$3.onClick(MainActivity.java:174)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.view.View.performClick(View.java:4084)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.view.View$PerformClick.run(View.java:16966)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.os.Handler.handleCallback(Handler.java:615)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.os.Handler.dispatchMessage(Handler.java:92)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.os.Looper.loop(Looper.java:137)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-12 19:22:12.189: E/AndroidRuntime(4524): at dalvik.system.NativeStart.main(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Class.classForName(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Class.forName(Class.java:217)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.load(Loader.java:334)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
03-12 19:22:12.189: E/AndroidRuntime(4524): ... 13 more
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Class.classForName(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Class.forName(Class.java:217)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.load(Loader.java:334)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)
03-12 19:22:12.189: E/AndroidRuntime(4524): ... 17 more
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 124 could not load needed library 'libopencv_core.so' for 'libjniopencv_core.so' (load_library[1093]: Library 'libopencv_core.so' not found)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Runtime.loadLibrary(Runtime.java:370)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.System.loadLibrary(System.java:535)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:444)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.load(Loader.java:368)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.load(Loader.java:315)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
03-12 19:22:12.189: E/AndroidRuntime(4524): ... 21 more
03-12 19:22:12.243: D/dalvikvm(4524): GC_CONCURRENT freed 2368K, 16% free 16864K/20039K, paused 12ms+3ms, total 50ms
Am I missing libopencv_core.so? If so, where can I find it built for version 2.4.2?
Thanks!
I'm sure by now you've figured it out. download javacv-0.5-cppjars.zip, inside it extract the contents of opencv-2.4.5-android-arm.jar. you'll find libopencv_core.so in there and several other .so files

Android Maps V2 App Crashing

I have made an app that uses Google Android Maps API V2 and I have followed every step in the guide provided by Google but it doesn't work unfortunely and it crashes every time I try to start it up. So I'm wondering what is the problem?
MainActivity.java
package com.android.maptest;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Maptest Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<permission
android:name="com.android.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.android.maptest.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:debuggable="true" >
<activity
android:name="com.android.maptest.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="api_key" />
</application>
</manifest>
Logcat
03-12 09:46:13.150: D/AndroidRuntime(1547): Shutting down VM
03-12 09:46:13.150: W/dalvikvm(1547): threadid=1: thread exiting with uncaught exception (group=0x410e22a0)
03-12 09:46:13.155: E/AndroidRuntime(1547): FATAL EXCEPTION: main
03-12 09:46:13.155: E/AndroidRuntime(1547): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.maptest/com.android.maptest.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-12 09:46:13.155: E/AndroidRuntime(1547): at
android.app.ActivityThread.access$600(ActivityThread.java:140)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.os.Looper.loop(Looper.java:137)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-12 09:46:13.155: E/AndroidRuntime(1547): at dalvik.system.NativeStart.main(Native Method)
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.setContentView(Activity.java:1924)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.maptest.MainActivity.onCreate(MainActivity.java:11)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.performCreate(Activity.java:5206)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 11 more
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:584)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:552)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.onCreateView(Activity.java:4849)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 20 more
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:574)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 23 more
03-12 09:51:21.560: I/Process(1547): Sending signal. PID: 1547 SIG: 9
Here a blog post I wrote on how to integrate Google Maps into you application:
Creating Google Map Application
From your error it look like you did not perform correctly steps 2-3 of the blog guide,
for adding Google Play services library into your application.
If you follow carefully the steps written in the guide you will end up with the end result you can see at the end of the post.
I assumed that you have already get Google Maps Android API v2 key and have Google Play services. If you not have already installed it then please follow below steps to solve this problem_
Step 1. you can found it in Android SDK Manager under Extras tick check box of -Google Play services install it and after complete installation, restart your Eclipse.
Step 2. Add library named_ google-play-services_lib found under the extras folder of your Android SDK setup folder to your Android project_
Path of google service lib_
{Your_Android_SDK_direct}\extras\google\google_play_services\libproject\google-play-services_lib
Ex. Location of this lib on My system_
C:\Program Files\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib
I hope this will solve your ploblem.
For me adding:
import com.google.android.gms.maps.SupportMapFragment;
And changing the xml to
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/header" />
resolved the problem. I hope you resolve it too!
Looks like you didn't add the Google Play Services library to your project.
It's located at {Android SDK}\extras\google\google_play_services
Add it as Android Library Project to Eclipse and then add it to your project.

Categories

Resources