ofx app running on boot [SOLVED]

Hi, an android newbie question:

I’ve been asked to do an installation with a few android devices. Its possible to program and ofx app on android that runs on boot?

I’ve been reading a little about it, but i am still not sure if that is currently possible.

Thanks in advance

Well, I solved it with a little research (at least work in android 4.3)

In the manifest add:

  
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />  

And inside the application tag in the manifest:

  
  
<receiver android:name=".OFReceiver">  
    <intent-filter >  
        <action android:name="android.intent.action.BOOT_COMPLETED"/>  
    </intent-filter>  
</receiver>  
  

After that, you need to create a Java class that listen to the BOOT_COMPLETED broadcast event (in the srcJava folder)

  
  
package cc.openframeworks.androidEmptyExample;  
  
import android.content.BroadcastReceiver;  
import android.content.Context;  
import android.content.Intent;  
  
public class OFReceiver extends BroadcastReceiver {  
  
    @Override  
    public void onReceive(Context context, Intent intent) {  
  
        if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){  
            Intent i = new Intent(context, OFActivity.class);  
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
            context.startActivity(i);  
        }  
    }  
}  
  

With this the emptyExample runs when boots ends. It takes a couple of minutes in my samsung galaxy nexus, but works as intended.