android - Set Intents category programmatically -


i have application following lines in androidmanifest:

<category android:name="android.intent.category.home" />  <category android:name="android.intent.category.default" />                             <category android:name="android.intent.category.monkey"/> 

my question is: possible set these options programmatically? mean, users able enable or disable options above.

what keep app launcher.

so, possible put condition on this, can make depending on user?

edition: edited question add suggestion of rawr.

here doing before calling main activity:

        intent myintent = new intent(v.getcontext(), mainactivity.class);          myintent.addcategory(intent.category_home);         myintent.addcategory(intent.category_default);                       myintent.addcategory(intent.category_monkey);         startactivity(myintent); 

if use these commands inside manifest, work. 1 cannot leave app pressing home button. adding categories manually above doesn't work.

any suggestions?

thank in advance!

when create intent can use addcategory specificy categories intent. according android docs, when resolving intent activities provide of categories specified used. example if did

intent = new intent(); i.addcategory(intent.category_home); i.addcategory(intent.category_default); 

you add home , default category intent along other custom categories wish. there you. can't tell purpose of intent leave @ that.

as behavior supplied in you're comment, think related need intent filter. setting category of intent not accomplish unless still include filter respond category.

<intent-filter>   <action android:name="android.intent.action.main" />   <category android:name="android.intent.category.home" />   <category android:name="android.intent.category.default" /> </intent-filter> 

setting intent filter in manifest effectivly listen categories set programatically. that's why still need corresponding category tags in manifest catch intent.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -