I have rewritten my question and this time I will be more specific. My problem is that I want to start my application every time I start my phone. For this I have a java file called bootreceiver.java
that I have the following:
package my.app.client;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.preference.PreferenceManager;
import android.util.Log;
public class BootReceiver extends BroadcastReceiver {
public final String TAG = BootReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "BOOT Complete received by Client !");
String action = intent.getAction();
if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent serviceIntent = new Intent(context, Client.class);
serviceIntent.setAction(BootReceiver.class.getSimpleName());
context.startService(serviceIntent);
}
}
}
So what I need to know is I have to tell you in my launcheractivity or what steps I should take for my bootreceiver to turn on the application every time I turn on my mobile. As for the manifest thing I understand it is just add:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<receiver android:name="my.app.client.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
In my case the name of my class is BootReceiver so I would have to put:
<receiver android:name="BootReceiver">
This I will put it in the manifest but I do not know what I have to put in my launcheractivity or what I have to do with bootreceiver I just have to add it to the manifest or do I have to do something else?
Have I been testing on my phone and muchas veces falla y no se arranca la aplicación
is there any way to fix it?
logcat:
01-01 00:04:02.360: E/Trace(1464): error opening trace file: No such file or directory (2)
01-01 00:04:02.410: W/asset(1464): Asset path /data/app/my.app.client-1.apk is neither a directory nor file (type=1).
01-01 00:04:02.780: W/asset(1464): Asset path /data/app/my.app.client-1.apk is neither a directory nor file (type=1).
01-01 00:04:02.820: D/AndroidRuntime(1464): Shutting down VM
01-01 00:04:02.820: W/dalvikvm(1464): threadid=1: thread exiting with uncaught exception (group=0x40acd930)
01-01 00:04:02.830: E/AndroidRuntime(1464): FATAL EXCEPTION: main
01-01 00:04:02.830: E/AndroidRuntime(1464): java.lang.RuntimeException: Unable to instantiate receiver my.app.client.receiver.BootReceiver: java.lang.ClassNotFoundException: Didn't find class "my.app.client.receiver.BootReceiver" on path: /data/app/my.app.client-1.apk
01-01 00:04:02.830: E/AndroidRuntime(1464): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2357)
01-01 00:04:02.830: E/AndroidRuntime(1464): at android.app.ActivityThread.access$1500(ActivityThread.java:141)
01-01 00:04:02.830: E/AndroidRuntime(1464): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310)
01-01 00:04:02.830: E/AndroidRuntime(1464): at android.os.Handler.dispatchMessage(Handler.java:99)
01-01 00:04:02.830: E/AndroidRuntime(1464): at android.os.Looper.loop(Looper.java:137)
01-01 00:04:02.830: E/AndroidRuntime(1464): at android.app.ActivityThread.main(ActivityThread.java:5041)
01-01 00:04:02.830: E/AndroidRuntime(1464): at java.lang.reflect.Method.invokeNative(Native Method)
01-01 00:04:02.830: E/AndroidRuntime(1464): at java.lang.reflect.Method.invoke(Method.java:511)
01-01 00:04:02.830: E/AndroidRuntime(1464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-01 00:04:02.830: E/AndroidRuntime(1464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-01 00:04:02.830: E/AndroidRuntime(1464): at dalvik.system.NativeStart.main(Native Method)
01-01 00:04:02.830: E/AndroidRuntime(1464): Caused by: java.lang.ClassNotFoundException: Didn't find class "my.app.client.receiver.BootReceiver" on path: /data/app/my.app.client-1.apk
01-01 00:04:02.830: E/AndroidRuntime(1464): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
01-01 00:04:02.830: E/AndroidRuntime(1464): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-01 00:04:02.830: E/AndroidRuntime(1464): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-01 00:04:02.830: E/AndroidRuntime(1464): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2352)
01-01 00:04:02.830: E/AndroidRuntime(1464): ... 10 more
01-01 00:05:47.000: I/Process(1464): Sending signal. PID: 1464 SIG: 9
If I reformulate the question is for you to explain to me that I am doing wrong from the logcat. Because it shows me not found if in my manifest I have my class ..
I also tried this and it did not work:
add the BootReceiver class inside another package, for example:
<receiver android:name="my.app.client.receiver.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
The project is , which I modify for educational purposes:
This is the project to import, click here
The application is called ZMaster Clean Pro (The application appears at the end), it is a client application, it is in a .zip file so you can IMPORT SO MUCH IN ANDROID AS ECLIPSE - The startup is put as a service, the issue is that when I open my application it is visible, but when I restart the startup it never opens, but I open it. Therefore, the layout of my application should be visible when I turn on my mobile phone. If you put it as an activity it will return an error in the logcat as cite.