Instead of declaring a pre-determined launcher activity in my manifest using an intent filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Could I, instead, be given programmatic control over the activity which gets run when the application launches?
I'm not able to find anywhere in the documentation which says I must use the intent filter approach... but I also don't see any discussion of the alternative(s).
http://developer.android.com/guide/topics/fundamentals/activities.html
http://developer.android.com/guide/topics/intents/intents-filters.html
Thanks.
As far as I know, it's not possible. Android creates or sets up the hard link of the App icons to their respective activities by looking at the manifest. If you don't set it, you will not find any icons/shortcuts for your app after you install it.
Related
I am developing a Huawei custom Theme. I was trying to change some Google apps (Documents, Sheets and Slides) icons. So I used as address their package name e.g. com.google.android.apps.docs.editors.slides
Since it didn't work, I tried with some activities, found in the manifest file, but no one worked yet. (for example com.google.android.apps.editors.homescreen.HomescreenActivity, which is the first one that appears when I open Slides);
So the question is:
is there a way to identify which is the main activity, nay, which is the activity who defines app icon?
Usually, the main activity declares the following intent filters (documentation) in order to indicate for the system that this activity is Main and is a launcher activity:
<activity android:name=".ActivityClassName">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I want to make my Android application invisible and work through a background task.
This part should work like these two apps, if anyone knows them:
https://www.keeperschildsafety.net/
https://www2.mspy.com/
I already found examples for making the app icon invisible, but I want to go one step further.
This is the site I found that on:
https://readyandroid.wordpress.com/hideunhide-app-icon-programmatically-android/
I also found some explanations that I should delete the <intent-filter>:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
But then I am not able to start my application.
On all other sites I read that this is not possible, but the two examples shown at the top prove that it is actually possible somehow.
I want to start my application once, then hide it and unhide it later.
I already know how to trigger the unhide. The only part that I need is the hiding and unhiding itself.
You need to remove the following line from your AndroidManifest.xml:
<category android:name="android.intent.category.LAUNCHER"/>
This will remove the application from the default launcher. However, you also need to add the following line such that your BroadcastReceiver is not completely ignored:
<category android:name="android.intent.category.DEFAULT"/>
You should NOT remove the line below - it is used to specify which Activity should launch first when your app is opened:
<action android:name="android.intent.action.MAIN"/>
also try this
<activity android:name=".MainActivity"
android:excludeFromRecents="true" ...
in your AndroidManifest.xml's activity declaration.
What needs to be done to make your app appear as an option app.
For eg, when I select an image file, android shows me a list of applications to open the file with, like Gallery,Photos etc.
I want that android also shows my app in this list.
How to achieve this? I am unable to understand which android classes to use for it? Or do I need to modify manifest file to add some specific intents?
By defining intent filter you can achieve this. You can register your Android components via intent filters for certain events.If a component does not define one, it can only be called by explicit intents. The key for this registration is that your component registers for the correct action, mime-type and specifies the correct meta-data.
Eg.
<activity android:name=".BrowserActivitiy"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
</intent-filter>
</activity>
Above code will register an Activity for the Intent which is triggered when someone wants to open a webpage.
Source: http://www.vogella.com/tutorials/AndroidIntent/article.html
As indicated by the tags, this is homework/classwork. (Note that it's really just an in class thing that my instructor can't seem to explain, so I'm turning to the interwebs).
We have an example made up of two apps: Sample1 and Sample2. The point of the example is to show calling into Sample2 from Sample1 using an intent. Sample 2 uses an intent filter to be launched by a certain intent. Here is a snipped from the manifest.
<activity
android:name=".Sample2"
android:label="#string/title_activity_Sample02" >
<intent-filter>
<action android:name="Sample02.intent.action.Thinger" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Sample01 invokes this using an intent:
Intent intent = new Intent("Sample02.intent.action.Thinger");
startActivity(intent);
This works fine, assuming that Sample02 is installed on the target device.
What confuses me is this bit in Sample01's manifest file:
<activity
android:name="com.example.Sample02.Sample02"
>
</activity>
I don't understand what this is for. It exists in addition to the declaration for Sample01 in the same file. Near as I can tell, I can remove it and everything works the same. Anyone know what this about? Thanks.
This is acknowledgment of simple02 app in simple01 app manifest. it is showing that we want to use simple02 method and function in simple01 app.
Is there a specifici reason why if I have MainActivity, it has it's own Icon, yet if I create SecondActivity it has a separate icon? If I download an app from the Play store it's all from one icon. Am I just being dumb? Or is there a specific reason why this is. Thanks so much!
Any activity that declares the following intent filter will have an icon in the system's app listing:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
If you only want one icon then only put this intent filter inside your main activity.
Each activity can be launched independently - and thereby can have its own icon - in the Launcher. Also, I think in later APIs, the icon can be displayed inside the Activity itself.