Android Base: Categorizzare un Intent Filter

Cominciamo qui una serie di Tips per chi desidera sviluppare applicazioni mobile su piattaforma Android.
Come ben sappiamo, la piattaforma Android è una piattaforma “aperta”. Una conseguenza di questo è che le nostre applicazioni girano con gli stessi privilegi delle applicazioni native.
E’ possibile, quindi, fare in modo che una nostra applicazione venga utilizzata al posto della Home nativa (essa stessa è una Activity) e per fare questo basta configurare il nostro AndroidManifest.xml in questo modo :
<code style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: black; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;"><span class="Apple-style-span" style="color: #660000;">&lt;activity</span> <span class="Apple-style-span" style="color: red;">android:name</span>="<span class="Apple-style-span" style="color: blue;">miaHome</span>"<span class="Apple-style-span" style="color: #660000;">&gt;</span>
  </span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">&lt;intent-filter&gt;</span></span><span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: black; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">
    </span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">&lt;action</span></span><span class="atn" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: red; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">android:name</span></span><span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: black; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span class="atv" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: blue; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">"android.intent.action.MAIN"</span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">/&gt;</span></span><span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: black; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">
    </span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">&lt;category</span></span><span class="atn" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: red; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">android:name</span></span><span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: black; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span class="atv" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: blue; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">"android.intent.category.HOME"</span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">/&gt;</span></span><span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: black; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">
    </span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">&lt;category</span></span><span class="atn" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: red; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">android:name</span></span><span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: black; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span class="atv" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: blue; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">"android.intent.category.DEFAULT"</span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">/&gt;</span></span><span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: black; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">
  </span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">&lt;/intent-filter&gt;</span></span><span class="tag" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-color: initial; border-style: initial; color: maroon; vertical-align: baseline; border-width: 0px; padding: 0px; margin: 0px;"><span class="Apple-style-span" style="font-size: x-small;">&lt;/activity&gt;</span></span></code>
Come si può vedere non abbiamo fatto altro che definire in Intent Filter (in prossimi Post parleremo più in dettaglio di cosa siano e a cosa servono), e scegliere per esso la categoria a cui appartiene anche la Home nativa ovvero android.intent.category.HOME, è stata inoltre inserita la cetegoria android.intent.category.DEFAULT per fare in modo che la nostra Activity sia quella di default quando si preme il punsante Home sul dispositivo.

RSS AngularJob

ddelfio Written by: