I have 3 activities (MainActivity, TwitterActivity, WebBrowserActivity).
WebBrowserActivity uses for showing web info from twitter.
Manifest:
1.
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
2.
<activity
android:name=".TwitterActivity"
android:label="#string/app_name"
android:launchMode="singleInstance" >
<!-- Used for OAuth callback -->
<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:host="callback"
android:scheme="x-bker-oauth-twitter" />
</intent-filter>
</activity>
3.
<activity android:name=".TwitterWebBrowser" />
Starting twitter:
Intent myIntent = new Intent(mContext, TwitterActivity.class);
mContext.startActivity(myIntent);
When twitt is posted I close TwitterActivity (using finish(); method) and MainActivity shows. Than I press Home Button and goes to Android, than press home button and press my app icon, and I goes to TwitterActivity, but I need to go to MainActivity. How do this?
It is only on android version 2.3.7 and below.
In your manifest entry for the TwitterActivity, change android:launchMode="singleInstance" to android:launchMode="singleTop".
I think you are setting launchMode because you want to be able to jump out to the Twitter app or web page to authorize the user from TwitterActivity, and then return back to the same instance of your TwitterActivity when done. In that case, TwitterActivity will be at the top of your task stack, so singleTop will tell the system to reuse it.
The problem with singleInstance is that it makes the activity the only activity in the task, which probably explains why the recents menu is launching the TwitterActivity. (more info in activity element docs).
If you really need to use singleInstance, you should consider assigning it to its own task and excluding it from recents, for example (use your own name for taskAffinity):
<activity
android:name=".TwitterActivity"
android:label="#string/app_name"
android:launchMode="singleInstance"
android:taskAffinity="com.example.twitter"
android:excludeFromRecents="true">
Related
I am at my wits end with this. I am trying to have the user click on a link in a text message and the phone direct them to my app. However it autommatically goes to browser. Please help!
My android manifest looks like this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main activity -->
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="adjustResize">
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host="www.myapp.com"/>
</intent-filter>
</activity>
Looking at every forum I am doing this correctly yet it still does not work. Please help!
You need to use a broadcast receiver, it is the receiver that has to be configured on the intents you're listening on, when such an intent takes place your receiver should bring to foreground an activity or do whatever else you need to.
Something like this may help you achieve what your trying to do :
https://stackoverflow.com/a/525086/1542720
I'm new to Android development and I would like to create an app that can launch a scheduled activity reminders from Google calendar.
I tried to do it with filters intents and it does not work, and I searched unsuccessfully for code examples.
Below is what I've done so far. This code is part of a manifest.
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="MasReceiver" >
<action android:name="android.intent.action.EVENT_REMINDER" />
</receiver>
I suspect that the system can't find MasReceiver. The name you supply for your broadcast receiver in the element has to be fully qualified. The documentation for the receiver element explains this in more detail.
So, I am going over tutorials to learn android and I have the bellow code which is giving me this warning in the title and the app will not run for some reason any help?
This is the code:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.learn.tam.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SPLASH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.learn.tam.StartingPoint"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
The part that is showing the error is the Second
< activity
You are advertising that any application on the device can start com.example.learn.tam.StartingPoint, and Lint is warning you that this is insecure.
Most likely, you do not need that <intent-filter> -- you only usually need those for activities that you are expecting other apps to start. Hence, the simplest way to get rid of this warning is to delete that <intent-filter> and use an explicit Intent when you start that activity (e.g., new Intent(this, StartingPoint.class)).
If you elect to keep the <intent-filter>, for whatever reason, please:
Do not use android.intent.action. as the prefix for your own invented actions -- come up with something else, such as com.example.learn.tam.
Add android:exported="false" to the <activity> element to say that, despite the fact that you have an <intent-filter>, you are not expecting other applications to start your activity
I have been developing a map app for Android. Initially I intended to make the main screen the map itself. After discussion with my boss, it has been decided that I make a normal (non-map) layout as my first screen and then have a button to access that map.
I have the first screen ready to be used. The name of this activity is LocateActivty.java. The name of the map activity is MainActivity.java. Since I initially developed the map activity first, it obviously continues to be opened as the first screen.
What changes should I make to the files (if any) and to any configuration files to make LocateActivity.java my main activity?
EDIT - Manifest code
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.aquamet.saramap.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.aquamet.saramap.LocateActivity"
android:label="#string/title_activity_locate"
android:parentActivityName="com.aquamet.sara.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.aquamet.sara.MainActivity" />
</activity>
</application>
The lines of XML in the manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Need to be moved from the Activity tags for MainActivity, and put inside the tags for LocateActivity. This will then mean that LocateActivity receives the Launcher intent when the user opens your application
Hi I have created a splash screen but I am not sure how to get it to start. I have tried putting it in the top folder but I can't get it to start, I realise this is because it is the last item I created on my app.
How do I get it to the top of the build path.
Have you placed your Splashscreen in your manifest.
Should place your Splashscreen as the first activity and then the main activity.
For eg:
//First Activity as Splashscreen
activity android:name=".SplashScreen"
android:screenOrientation="portrait"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
//Splashscreen activity ends here
Your main activity followed by remaining activities.
<activity android:name=".Aptv"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
<intent-filter>
action android:name="com.ayansys.aptv.Aptv" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>