我想为谷歌电视制作一个启动器。我已经制作了我的apk。 当Android设备准备好(启动时)时,如何自动启动我的应用程序?
感谢您的帮助。
答案 0 :(得分:1)
如果我理解你想要的东西,我在创建我的应用程序PS Lock时需要这样的东西,所以:
您必须添加权限:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
您必须声明接收器,以接收引导的广播操作:
<receiver android:name=".BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
最后,您需要一个班级来接收启动并调用您的主要活动:
public class BootReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context,Intent intent){
if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
Intent it = new Intent("ACTION"); //or new Intent(context,YourActivity.class);
context.startActivity(it);
}
}
}
答案 1 :(得分:-1)
要启动应用程序,请转换Intent以使用Intent.toUri()方法将该应用程序启动到Uri,然后使用Anymote的fling事件将其发送到电视。