开发者

How to make my app persistence [closed]

开发者 https://www.devze.com 2023-03-27 04:20 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist

Closed 9 years ago.

Improve this question

I'm a new with Android. I want to make an applic开发者_运维百科ation that always running. User can't switch to other application, if my app is exited then it will be launched automatically.


You can achieve this with intent filters in your manifest, on your activity.

    <category android:name="android.intent.category.HOME" />
    <category android:name="android.intent.category.DEFAULT" />

This makes your activity an alternative for the home-app, but the user needs to select your app as the default app the first time it's run. There is no other way.

After the user selects your app as the default home app it will be launched every time 'home' is pressed. You can then capture the other buttons as usual and do whatever you want (e.g. nothing when 'back' is pressed).


into AndsroidManifest insert this: <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" />

0

精彩评论

暂无评论...
验证码 换一张
取 消