RuntimeException: Unable to instantiate receiver - java

I am attempting to launch an activity after the screen is unlocked and am getting the error log below. I looked at the other posts regarding my issue but now of them solved my problem
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate receiver com.me.phone.Receive: java.lang.ClassNotFoundException: com.me.phone.Receive
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2239)
at android.app.ActivityThread.access$1600(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4918)
at java.lang.reflect.Method.invokeNative(Native Method)
Mainifest
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-feature android:name="android.hardware.camera" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.me.phone.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>
<receiver android:name=".Recieve" >
<intent-filter
android:enabled="true"
android:exported="false" >
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
</manifest>
Reciever
package com.me.phone;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class Recieve extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent intent)
{
Intent activity = new Intent(context, MainActivity.class);
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(activity);
}
}

Could it be that "Receive" is spelled two different ways in your example?
From the exception:
...java.lang.ClassNotFoundException: com.me.phone.Receive
From the manifest:
<receiver android:name=".Recieve" >

Related

Caused by: java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.geo.API_KEY"

I am trying to compile a simple map display on in my activity, but the app keeps closing. This is my first time working with an API in Android Studio. Here is my complete manifest code. because when I debug the code it shows API key not found.
Check that is in the element of AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.tensorflow.lite.examples.detection">
<uses-sdk />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/blind"
android:label="#string/app_name"
android:roundIcon="#drawable/blind"
android:supportsRtl="true"
android:theme="#style/AppTheme.ObjectDetection">
<activity android:name=".Navigation.MapsActivity"
android:exported="true"/>
<activity android:name=".Navigation.GestureDetect"
android:exported="true"/>
<activity android:name=".Navigation.Navigation"
android:exported="true"/>
<activity
android:name=".Reminder.NotificationMessage"
android:exported="true" />
<activity
android:name=".Home"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".Navigation.RebootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
</application>
</manifest>
Here is the complete error after debugging the code:-
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.tensorflow.lite.examples.detection, PID: 11755
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.tensorflow.lite.examples.detection/org.tensorflow.lite.examples.detection.Navigation.MapsActivity}: android.view.InflateException: Binary XML file line #75: Binary XML file line #75: Error inflating class fragment
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:528)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:910)
Caused by: android.view.InflateException: Binary XML file line #75: Binary XML file line #75: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #75: Error inflating class fragment
Caused by: java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
at com.google.maps.api.android.lib6.drd.p.a(:com.google.android.gms.dynamite_mapsdynamite#222413050#22.24.13 (040406-0):6)
at com.google.maps.api.android.lib6.auth.f.i(:com.google.android.gms.dynamite_mapsdynamite#222413050#22.24.13 (040406-0):1)
at com.google.maps.api.android.lib6.impl.l.a(:com.google.android.gms.dynamite_mapsdynamite#222413050#22.24.13 (040406-0):24)
at com.google.android.gms.maps.internal.CreatorImpl.b(:com.google.android.gms.dynamite_mapsdynamite#222413050#22.24.13 (040406-0):7)
at com.google.android.gms.maps.internal.CreatorImpl.logInitialization(:com.google.android.gms.dynamite_mapsdynamite#222413050#22.24.13 (040406-0):3)
at com.google.android.gms.maps.internal.g.ba(:com.google.android.gms.dynamite_mapsdynamite#222413050#22.24.13 (040406-0):5)
at eu.onTransact(:com.google.android.gms.dynamite_mapsdynamite#222413050#22.24.13 (040406-0):4)
at android.os.Binder.transact(Binder.java:627)
at com.google.android.gms.internal.maps.zza.zzc(com.google.android.gms:play-services-maps##18.1.0:2)
at com.google.android.gms.maps.internal.zze.zzl(com.google.android.gms:play-services-maps##18.1.0:4)
at com.google.android.gms.maps.MapsInitializer.initialize(com.google.android.gms:play-services-maps##18.1.0:12)
at com.google.android.gms.maps.MapsInitializer.initialize(com.google.android.gms:play-services-maps##18.1.0:1)
at com.google.android.gms.maps.zzav.zzc(com.google.android.gms:play-services-maps##
at com.google.android.gms.dynamic.DeferredLifecycleHelper.onInflate(com.google.android.gms:play-services-base##18.0.1:1)
at com.google.android.gms.maps.SupportMapFragment.onInflate(com.google.android.gms:play-services-maps##18.1.0:9)
at androidx.fragment.app.Fragment.onInflate(Fragment.java:1561)
at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:106)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:356)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:335)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:737)
E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:870)
at android.app.Activity.setContentView(Activity.java:2758)
at org.tensorflow.lite.examples.detection.Navigation.MapsActivity.onCreate(MapsActivity.java:273)
at android.app.Activity.performCreate(Activity.java:7227)
at android.app.Activity.performCreate(Activity.java:7218)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
generate google api key
import the code your AndroidManifest.xml file.
Create google api key enter link description here
Enter the Key you got in the value field
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/api_key" />
You have to get api_key and declare in AndroidManifest.xml just like shown on the error.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.tensorflow.lite.examples.detection">
<uses-sdk />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/blind"
android:label="#string/app_name"
android:roundIcon="#drawable/blind"
android:supportsRtl="true"
android:theme="#style/AppTheme.ObjectDetection">
<activity android:name=".Navigation.MapsActivity"
android:exported="true"/>
<activity android:name=".Navigation.GestureDetect"
android:exported="true"/>
<activity android:name=".Navigation.Navigation"
android:exported="true"/>
<activity
android:name=".Reminder.NotificationMessage"
android:exported="true" />
<activity
android:name=".Home"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".Navigation.RebootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_API_KEY"/>
</application>
</manifest>

Phone State Receiver Not working in Oppo

I created a basic app to check whether broadcast is received when phone state is changed, but it is not working. I tried with making outgoing call and incoming calls too. I realized these are common issues with Vivo, Honor etc. Here is Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jss.servicetester">
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".ReceiverMe">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>
</manifest>
And here is code for receiver:
package jss.servicetester;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
/**
* Created by DELL WORLD on 5/28/2017.
*/
public class ReceiverMe extends BroadcastReceiver {
String LOGTAG = "Receiver";
#Override
public void onReceive(Context context, Intent intent) {
Log.d(LOGTAG, "action:" + intent.getAction());
}
}
Can anyone help me.
started working in oppo F3 after making some changes in battery options for application. Like Unfreeze app in background.

Device administrator privilege to android app

I know similar questions has been asked many times but still i was unable to get my solution from any of it. I am quite new to android & JAVA so please keep that in mind :) .I am working on some security related experimental projects at work & trying to give my android application device administrator privilege. I have one SampleDeviceAdministrator app which works fine. I want to use reuse the same code to my application so that when my application is launched it gets device admin access too.For that i have included the java classes from former app to my app & i am trying to call the same code to my app thru former app. Here are screenshots of MainActivity.java from sample app.
package com.connect;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
public class Droidian extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
PackageManager i = getApplicationContext().getPackageManager();
i.setComponentEnabledSetting(getComponentName(),PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
if(isMyServiceRunning()==false)
{
startService(new Intent(getApplicationContext(), DroidianService.class));
Log.i("com.connect","startService");
}
}
private boolean isMyServiceRunning() {
ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (DroidianService.class.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
}
Here is Droidian.java which is main class for my application.
package com.connect;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
public class Droidian extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
PackageManager i = getApplicationContext().getPackageManager();
i.setComponentEnabledSetting(getComponentName(),PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
if(isMyServiceRunning()==false)
{
startService(new Intent(getApplicationContext(), DroidianService.class));
Log.i("com.connect","startService");
}
}
private boolean isMyServiceRunning() {
ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (DroidianService.class.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
}
& here AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hidden.droidian"
android:versionCode="2"
android:versionName="2.0" xmlns:tools="http://schemas.android.com/tools">
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" tools:ignore="OldTargetApi"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<supports-screens android:resizeable="true"
android:largeScreens="true"
android:xlargeScreens="true"
/>
<application
android:icon="#drawable/launcher"
android:label="#string/app_name"
android:theme="#style/Invisible"
android:allowBackup="false"
android:persistent="true">
<activity
android:name="com.connect.Droidian"
android:excludeFromRecents="true">
</activity>
<activity
android:name="com.connect.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>
<activity
android:name="com.connect.Dialog"
android:excludeFromRecents="true">
</activity>
<activity
android:name="com.connect.CameraView"
android:excludeFromRecents="true">
</activity>
<activity
android:name="com.connect.VideoView"
android:excludeFromRecents="true">
</activity>
<service android:name="com.connect.DroidianService"
android:enabled="true"
android:exported="true"
android:persistent="true">
</service>
<service android:name="com.connect.RecordService">
</service>
<receiver android:name="com.connect.ServiceReceiver"
android:enabled="true"
android:exported="true"
android:persistent="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.PHONE_STATE" />
<action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<receiver
android:name="com.connect.SampleDeviceAdminReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN" >
<meta-data
android:name="android.app.device_admin"
android:resource="#xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.QUICKBOOT_POWERON" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" android:required="true"/>
<uses-permission android:name="android.permission.READ_SMS" android:required="true" />
<uses-permission android:name="android.permission.WRITE_SMS" android:required="true" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" android:required="true" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" android:required="true"/>
<uses-permission android:name="android.permission.READ_CONTACTS" android:required="true" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:required="true" />
<uses-permission android:name="android.permission.GET_TASKS" android:required="true" />
<uses-permission android:name="android.permission.WAKE_LOCK" android:required="false" />
<uses-permission android:name="android.permission.CALL_PHONE" android:required="true" />
<uses-permission android:name="android.permission.SEND_SMS" android:required="true" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" android:required="false" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" android:required="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:required="true" />
<uses-permission android:name="android.permission.CAMERA" android:required="true" />
<uses-permission android:name="android.permission.RECORD_AUDIO" android:required="false" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" android:required="true" />
<uses-permission android:name="android.permission.RECEIVE_SMS" android:required="true" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
</manifest>
When I run my application, i get JAVA Runtime nullpointer exception. Here is snippet from logcat:
12-10 13:47:42.261 4435-4435/com.hidden.droidian E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.hidden.droidian, PID: 4435
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=0, data=null} to activity {com.hidden.droidian/com.connect.MainActivity}: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.pm.ActivityInfo.parentActivityName' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:3699)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)
at android.app.ActivityThread.-wrap16(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.pm.ActivityInfo.parentActivityName' on a null object reference
at android.app.Activity.onCreate(Activity.java:905)
at com.connect.Droidian.onCreate(Droidian.java:16)
at com.connect.MainActivity.onActivityResult(MainActivity.java:54)
at android.app.Activity.dispatchActivityResult(Activity.java:6428)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)
            at android.app.ActivityThread.-wrap16(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Also, my application is supposed to be a hidden application so no launcher is created however, to execute device admin permission, launcher is required i suppose. If anyone could look into it would be great. Please let me know if i need to provide any more information. Thanks!
I think you forgot to post screenshots.
First of all, if Droidian.java is the main class for your app why it isn't set as launcher in Manifest file?
It should be like this:
<activity
android:name="com.connect.Droidian"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And there is one and only one LAUNCHER in an app.
Let me know if this helps you.

GCM Android Client Not Firing WakefulService?

I have literally followed the examples for implementing GCM inside an android app and the app is receiving the messages using the following code:
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// Explicitly specify that GcmIntentService will handle the intent.
ComponentName comp;
comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
The problem is that the GcmIntentService (public class GcmIntentService extends IntentService) is never being run? Am I missing something or should it usually fire the onHandleIntent method?
In case in any way related the Manifest file is below, thanks in advance:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.diversivi.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19"/>
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<activity
android:name=".DemoActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.diversivi.test" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.diversivi.test.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.diversivi.test.permission.C2D_MESSAGE" />
</manifest>
I don't see your GcmIntentService service declared in the manifest. That could be the problem.
In addition, the following line
comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
assumes that the GcmIntentService class is in the main package of your app (i.e. its full name is com.diversivi.test.GcmIntentService). If that's not the case, the broadcast receiver can't find the service class.

Android Bluetooth_admin permission error

Regarding Android bluetooth discovery.
Getting this error from manifest permission error. However, the only errors that I found posted, was that they forgot to put the permission outside the application. This is however not the case here.
The program is tested on a Galaxy S2 running Jelly Bean 4.1.
The error is as follows:
03-19 13:08:03.933: W/dalvikvm(12616): threadid=1: thread exiting with uncaught exception (group=0x413082a0)
03-19 13:08:03.938: E/AndroidRuntime(12616): FATAL EXCEPTION: main
03-19 13:08:03.938: E/AndroidRuntime(12616): java.lang.SecurityException: Need BLUETOOTH_ADMIN permission: Neither user 10004 nor current process has android.permission.BLUETOOTH_ADMIN.
Basically the manifest looks like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.motioncontrol"
android:versionCode="1"
android:versionName="1.0" >
<user-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:debuggable="true"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.motioncontrol.Main"
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=".AccelerometerDat"
android:label="#string/accelerator_title" />
<activity
android:name=".GyroscopeData" />
<activity
android:name=".Gravitydat" />
<activity
android:name=".Linearacc" />
<activity
android:name=".Bluetooth" />
<activity
android:name=".CheckBluetooth" />
<activity
android:name=".About"
android:label="#string/about_title"
android:theme="#android:style/Theme.Dialog" />
</application>
</manifest>
And the class where the error occurs:
private void doDiscovery() {
if (D) Log.d(TAG, "doDiscovery()");
// Indicate scanning in the title
setProgressBarIndeterminateVisibility(true);
setTitle(R.string.scanning);
Log.d(TAG, "indicates scanning");
// Turn on sub-title for new devices
findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
Log.d(TAG, "Set up sub-title for new devices");
// If we're already discovering, stop it
if (mBtAdapter.isDiscovering()) {
mBtAdapter.cancelDiscovery();
Log.i(TAG, "Already running discovering, stop it!");
}
// Request discover from BluetoothAdapter
mBtAdapter.startDiscovery();
Log.d(TAG, "Request discover form BluetoothAdapter");
}
Hope for an answer, what is going wrong :).
Thanks!
Change
<user-permission android:name="android.permission.BLUETOOTH_ADMIN" />
to
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<user-permission> is used to regulate the access to the current component by other application. You should try <uses-permission> to get the privilege.

Categories

Resources