Launching given activities directly - android

I'd like to create run configurations within Eclipse to launch a given Android activity directly so I don't have to run through my entire application to get to it. In my manifest, I've declared the activity like so:
<activity
android:name=".AlternativeActivity"
android:label="#string/title_alternative_activity"
android:exported="true">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mysite.AlternativeActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity
However, in Eclipse, I'm seeing the following warning:
Exported activity does not require permission.
How do I resolve this warning?

Exported activities (activities which either set exported=true or
contain an intent-filter and do not specify exported=false) should
define a permission that an entity must have in order to launch the
activity or bind to it. Without this, any application can use this
activity.
Protip: Place your cursor on the warning, press CTRL + 1 and select "Explain Issue".

Related

Android deep links opens in the app I linked from instead of launching a separate instance of my app

I am using react-native. Deep linking is working great for ios. For Android however, I can't seem to figure out how to open my app properly from deep links.
When opening a deep link from e.g. Firefox, my app is launched inside the firefox window. It is the same when I use a deep link-tester app. Everything works as intended with the app with the exception that it is not launched from the proper app.
What am I doing wrong? Here is an excerpt from my AndroidManifest.xml:
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
Take a look at https://developer.android.com/guide/components/activities/tasks-and-back-stack
When declaring an activity in your manifest file, you can specify how the activity should associate with a task using the element's launchMode attribute.
The launchMode attribute specifies an instruction on how the activity should be launched into a task. There are four different launch modes you can assign to the launchMode attribute:
Try putting android:launchMode="singleTask" on your activity tag
The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time.
https://developer.android.com/guide/components/activities/tasks-and-back-stack#ManifestForTasks
Further background reading includes (and many other things you can try):
FLAG_ACTIVITY_NEW_TASK clarification needed
Android Task Affinity Explanation

How to choose an activity as a starter activity while launching an app?

I come up with a strange problem while trying to set "SignUpActivity" as my starter activity. I tried different ways but either I am getting an error or "mainActivity" is popping up as a starter activity.
My "AndroidManifest.xml" file has the following code.
<activity
android:name=".SignUpActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity" />
the above code gives me the error as shown in image
As the error states activity must be exported or contain an intent-filter
so, I did
<activity
android:name=".MainActivity"
android:exported="true"/>
and also tried adding intent-filter to activity. Of course, these methods make error go away but my app starts with MainActivity, not with SignUpActivity. What should I do to slove this issue?
Your AndroidManifest.xml is set correctly, check your run/debug configuration is set to 'App', not 'MainActvity'
If the 'App' configuration is missing - you will need to add it by first selecting 'Edit Confurations'
There are similar posts about this error msg.
Check the run configuration , probably you need to edit the app configuration and choose it to run.
As guided by #Eric I selected an option "app" from the run configuration which solved my problem. Previously, somehow it was set to MainActivity which was causing the issue. I have attached an image to demonstrate the solution for future readers.

Two Instances opened When opening application from dynamicaLink and from launcher icon?

I ran into an issue in my Android Application where whenever I open my app through a dynamic link shared on Whatsapp, it will open in the same Whatsapp Application. I can see by going to the recent task that there is only one Application in a recent task which is Whatsapp and I can see my application inside it.
If I open my app from launcher icon then it will also create a new Application and there will be two application in recent tasks. My Splashscreen looks like this -
<activity
android:name=".SplashScreen"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You should added attribute in your activity
android:launchMode="singleTask"
In general it is better to use a dedicated Activity for sharing from other applications. Another app should not launch your main (root) Activity to share, it should launch a different Activity. That Activity can then launch your main (root) Activity in a new task (if necessary). You need to consider the user's behaviour and make sure that you don't confuse the user with multiple tasks.

Change Android App starting activity

I'm trying to change the start up activity.
I created an activity when the app loads but I want to add a screen before that, I'm not sure where to change the Android manifest to load a certain layout/activity when the app starts.
The startup activity [Launcher Activity] is declared in the projects' AndroidManifest.xml file
Look for that activity tag in the manifest which looks like this
<activity android:name=".Main"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Look at the attribute android:name. Main is the class which is launched when the app starts. Currently your calendar activity name should be there. Change that to the .classpath of your activity that you want to launch.
That should do it. You may also want to do the hello world application in the tutorials and go through the docs a little to see how Android Applications work.
From here
Just create another activity and set it as Launcher Activity and after a timer (if that's your achieve) just call the other activity!

Android Lint complaining about activity not registered in AndroidManifest, but it is

When I run Android Lint on my project I get the following warning:
The org.slaytanic.SIMLockedRingNotifier.SIMLockedRingNotifierActivity is not registered in the manifest
Issue: Ensures that Activities, Services and Content Providers are registered in the manifest
Id: Registered
Activities, services and content providers should be registered in the AndroidManifext.xml file using , and tags.
If your activity is simply a parent class intended to be subclassed by other "real" activities, make it an abstract class.
http://developer.android.com/guide/topics/manifest/manifest-intro.html
SIMLockedRingNotifierActivity.java
package org.slaytanic.SIMLockedRingNotifier;
public class SIMLockedRingNotifierActivity extends Activity {
[...]
AndroidManifest.xml
<application
android:icon="#drawable/application_icon"
android:label="#string/app_name" >
<activity
android:name=".SIMLockedRingNotifierActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
[...]
I've also tried to replace the activity's android:name attribute with the full pathandroid:name="org.slaytanic.SIMLockedRingNotifier.SIMLockedRingNotifierActivity" but I get the same warning. The app works perfectly and that activity is correctly added to the launcher. How can I get rid of it? Am I missing something?
I tested with two quick apps in Eclipse and it does appear that Lint is unable to determine if an Activity that uses a "non-standard" package name with upper-case characters is correctly added to the AndroidManifest.xml.
The issue is logged in their bug tracker already.

Categories

Resources