I try to show a simple toast message on phone startup.
I wasted almost a day trying to figure out why my code did not work.
Here is the full error:
Unable to instantiate receiver com.debug.receivebootcomplete.debug.BroadcastReceiverClass: java.lang.ClassNotFoundException: com.debug.receivebootcomplete.debug.BroadcastReceiverClass
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.debug.receivebootcomplete.debug">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:allowBackup="true" android:icon="#mipmap/icon" android:label="#string/app_name">
<receiver android:name=".BroadcastReceiverClass" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
And my class:
namespace Debug
{
class BroadcastReceiverClass:BroadcastReceiver
{
public override void OnReceive (Context context, Intent intent)
{
Toast.MakeText (context,"Work",ToastLength.Short).Show ();
}
}
}
In emulator debug the application throw the java.lang.ClassNotFoundException and on phone when reboot the application crash.
Thank you in advance!
Thanks #Talha!
My error was generated by the intent-filter tag. I have no idea why because in every topic that I saw everybody used that tag in Manifest file.
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
So I remove it and add
[BroadcastReceiver]
[IntentFilter(new[] {Intent.ActionBootCompleted})]
to the BroadcastReceiver class.
Related
The following code was written to snooze the currently ringing alarm. It is working fine in android emulator and behaving differently in different mobiles. Mobiles with API 23 are throwing an intent not found exception. Mobiles with API >23 are not throwing an exception, but failing to snooze.Please help me in resolving this issue.
public class AlarmReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Intent a = new Intent();
a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
a.setAction(AlarmClock.ACTION_SNOOZE_ALARM);
context.startActivity(a);
}
}
Here is the manifest file,
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.sriyanksiddhartha.fragmentdemo"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<uses-permission android:name="com.android.alarm.permission.SNOOZE_ALARM"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
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=".AlarmReceiver">
<intent-filter>
<action android:name="com.android.deskclock.ALARM_ALERT"/>
<action android:name="com.android.alarmclock.ALARM_ALERT"/>
</intent-filter>
</receiver>
</application>
</manifest>
exception in mobiles
I am trying to send crash reports to email but when my app crashes nothing happens. I tried messing around with configurations but i just kept getting errors (unknown member mostly, wth that is). Here's my code for the class.
#ReportsCrashes(
mailTo = "me#gmail.com")
public class MyApplication extends Application
{
#Override
public void onCreate() {
super.onCreate();
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
My manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ghostdevelopment.ueni2"
android:versionCode="1"
android:versionName="1.0"
android:debuggable="true">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="25" />
<application
android:name="MyApplication"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:label="#string/app_name"
android:name="com.ghostdevelopment.ueni2.MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="Ship Database"
android:name=".ShipInfo" />
</application>
</manifest>
According to your logcat it appears that your app has not included the ACRA library. You need to configure your build so that ACRA is included in your APK.
I have BroadcastReceiver which listens for ACTION_SHUTDOWN and some other actions.
My problem is, when I shutdown my android device(2.3.6) BroadcastReceiver is catching ACTION_SHUTDOWN two times. Problem is only with ACTION_SHUTDOWN and not with other actions.
When I run same code on emulator, it works fine.
Guys please help me. Here is my code:
my BootReceiver.java
public class BootReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if(Intent.ACTION_SHUTDOWN.equalsIgnoreCase(intent.getAction())) {
Log.i("Boot Receiver - Shutdown event");
// database operation
}
if(Intent.ACTION_BOOT_COMPLETED.equalsIgnoreCase(intent.getAction())) {
// some operation
}
if(Intent.ACTION_AIRPLANE_MODE_CHANGED
.equalsIgnoreCase(intent.getAction().intern())) {
// some operation
}
if(ConnectivityManager.CONNECTIVITY_ACTION
.equalsIgnoreCase(intent.getAction())) {
// some operation
}
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xyz.ui"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/spota"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name="com.xyz.UserActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.xyz.BootReceiver">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.intent.action.BATTERY_CHANGED" />
<action android:name="android.intent.action.AIRPLANE_MODE"/>
</intent-filter>
</receiver>
</application>
And here is the Logcat entries
05-03 16:37:23.826: I/xyz(2337): Boot Receiver - Shutdown event
05-03 16:37:23.881: I/xyz(2337): Inserting Data
05-03 16:37:28.514: I/xyz(2337): Boot Receiver - Shutdown event
05-03 16:37:28.529: I/xyz(2337): Inserting Data
Thanks!
you can add a flag to avoid this.
once you received this intent, set the flag.
if(flag)
{
do sth.
flag =0 ;
}
else
{
ignore.
}
HY!
I always get the ActivityNotFound Error, but i already have my Activity declared in the Manifest.
Whats wrong?
Error:
10-17 20:28:24.881: ERROR/AndroidRuntime(2141): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.korn.supplierplan/com.korn.supplierplan.view.LVEntries}; have you declared this activity in your AndroidManifest.xml?
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.korn.supplierplan"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name = "android.permission.INTERNET"> </uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".view.Login"
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=".view.LVEntries"></activity>
</application>
</manifest>
Calling:
Intent i = new Intent (Login.this,LVEntries.class);
i.putExtra("JSON", array.toString());
startActivity(i);
The problem is in how you are naming the Activities in you Manifest file.
I'm guessing your class files are named Login.java not view.Login.java, am I right? If so change this:
<activity android:name=".view.Login" android:label="#string/app_name">
To This
<activity android:name="Login" android:label="#string/app_name">
Do the same for LVEntries
If they are named like view.Login.java then remove the prepended view. in the name.
am having a little trouble here. i don't know why i am getting a SecurityException, when trying to install my AppWidget on the home screen?. i don't know what will help to solve this but here is the simplified logcat output and my Android Manifest for starters:
11-30 18:02:16.454: ERROR/AndroidRuntime(287): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.appwidget.action.APPWIDGET_CONFIGURE cmp=com.MuchachaApps.WeatherViewer/.WeatherForecastConfigure (has extras) } from ProcessRecord{44e58dc8 287:android.process.acore/10001} (pid=287, uid=10001) requires null
11-30 18:02:16.454: ERROR/AndroidRuntime(287):atandroid.os.Parcel.readException(Parcel.java:1218)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.os.Parcel.readException(Parcel.java:1206)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1214)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Activity.startActivityForResult(Activity.java:2749)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.startActivityForResult(Launcher.java:969)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.addAppWidget(Launcher.java:1148)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.onActivityResult(Launcher.java:379)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Activity.dispatchActivityResult(Activity.java:3828)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.ActivityThread.deliverResults(ActivityThread.java:3325)
11-30 18:02:16.454: ERROR/AndroidRuntime(287):... 11 more
My Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MuchaaApps.WeatherViewer"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<service android:name= "weatherForecast"></service>
<activity android:name=".WeatherForecastConfigure" android:label="#string/app_name"></activity>
<receiver android:name="WeatherWidgetProvider" android:label="Weather Forecast">
<intent-filter>
<action android:name= "android.appwidget.action.APPWIDGET_UPDATE"></action>
</intent-filter>
<intent-filter>
<action android:name="com.MuchaaApps.WeatherViewer.WEATHER_UPDATE"></action>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/weather_appwidget_info"></meta-data>
</receiver>
</application>
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
if you need any other information, please let me know. Thank you
Do you have a configuration Activity that's supposed to come up when you add the widget to the launcher? If so, you need to add an APPWIDGET_CONFIGURE action to your intent-filter. If not, you need to remove the android:configure attribute from your appwidget-provider XML.
Having one but not the other is the problem.