1.How to launch/open application when the device is just open?
2.How to launch/open application when the device is just unlocked/exit from lock state?
(I mean, how to recognize these events?)
10q,
David
This is my new code:
In Manifest:
<receiver
android-permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:name="BootReciver" >
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.SCREEN_ON" />
</intent-filter>
</receiver>
In BootReciver.java I added to my project:
package development.Grandpa;
import android.content.BroadcastReceiver;
public class BootReciver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Intent intent1 = new Intent(context, Grandpa.class);
context.startActivity(intent1);
}
}
Where Grandpa class is my Main Activity.
In addition, I'm running the code directlly on my device and that is what I'm getting in the LogCat:
??-?? ??:??:??.???: INFO/(): Unable to open log device '/dev/log/main': No such file or directory
I also tried to add one reciver for boot and another one for ScreenOn (with two classes) like this:
<receiver
android:name="ScreenOnReciver" >
<intent-filter >
<action android:name="android.intent.action.SCREEN_ON" />
</intent-filter>
</receiver>
<receiver
android-permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:name="BootReciver" >
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
But it didn't help also.
Edit:
This it what I'm getting in logcat after:
1.Run the application
2.Exit from the application
3.Lock Screen
4.Unlock Screen
11-13 23:59:26.140: ERROR/AndroidRuntime(3640): Set to default setting_6 : region=- Duser.region=IL propRegn=IL
11-13 23:59:26.710: ERROR/AndroidRuntime(3649): Set to default setting_6 : region=-Duser.region=IL propRegn=IL
11-13 23:59:33.246: ERROR/power(244): *** set_screen_state 0
11-13 23:59:33.246: ERROR/SensorManager(244): unregisterListener:: all sensors, listener = com.android.server.PowerManagerService$13@40517118
11-13 23:59:33.593: ERROR/LockPatternKeyguardView(244): Phone is boot completed. so can send broadcast message for music player
11-13 23:59:35.286: ERROR/power(244): *** set_screen_state 1
11-13 23:59:35.286: ERROR/SensorManager(244): registerListener :: handle = 3 name= GP2A Light Sensor delay= 200000 Listener= com.android.server.PowerManagerService$13@40517118
11-13 23:59:35.286: ERROR/SensorManager(244): reg :: handle = 3
11-13 23:59:35.336: ERROR/LockPatternKeyguardView(244): Phone is boot completed. so can send broadcast message for music player
11-13 23:59:36.360: ERROR/SlidingTab(244): onTouchEvent() : thresholdReached !
11-13 23:59:36.380: ERROR/KeyguardViewMediator(244): Phone is boot completed. so can broadcast
11-13 23:59:36.400: ERROR/MTPRx(3319): In MtpReceiverandroid.intent.action.USER_PRESENT
11-13 23:59:36.410: ERROR/MTPRX(3319): Battery charging. plugType = 2
11-13 23:59:36.410: ERROR/MTPRx(3319): USB charging
11-13 23:59:36.416: ERROR/MTPRx(3319): usb is connected, set value in Settings.System, result = true
11-13 23:59:36.416: ERROR/MTPRx(3319): usb mode = 0
11-13 23:59:36.416: ERROR/MTPRx(3319): usb debugging is enabled
Edit2:
I have only these "Exception" in the logcat:
11-14 00:22:15.313: WARN/WindowManager(244): android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
11-14 00:22:15.313: WARN/WindowManager(244): Caused by: java.lang.reflect.InvocationTargetException
11-14 00:22:15.313: WARN/WindowManager(244): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x1010059 a=-1}