I am having an issue to start the application on android startup, the problem is how to put the listeners on the "android.permission.RECEIVE_BOOT_COMPLETED" from the manifest ( on the mobile application project from Flash builder) to the native extension ??
basically on the manifest I have something like this :
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application>
<receiver android:enabled="true" android:name="EXTENSION_PACKAGE.application.receivers.ApplicationStartupReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
And on the native side : the listener should be like :
package EXTENSION_PACKAGE;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;
public class ApplicationStartupReceiver extends BroadcastReceiver implements FREFunction {
@Override
public void onReceive(Context context, Intent intent) {
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
Intent serviceIntent = new Intent("com.myapp.MySystemService");
context.startService(serviceIntent);
}
}
@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {
// TODO Auto-generated method stub
return null;
}
}
My questions are :
- The "EXTENSION_PACKAGE" is the package name from the native project or the extension id ?
- The ".application" refers to the application or I don't need it ?
I hope that you understand this situation and Thank you in advance.
-----------------------------------------EDIT----------------------------------------
After few attempts and tests, I have changed these values :
<receiver android:enabled="true" android:name="NATIVEPROJECTPACKAGE.application.receiver.ApplicationStartupReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
And :
Intent serviceIntent = new Intent("air.APPLICATION_ID"); // from the APPLICATION.XML
and now it seems to work, the only problem now, is that it crashes on the android startup, I recieve an alert saying : "Unfortunately the application 'APPLICATION NAME' has stopped" And of course, if I launch the application, it works, ...