Exported activity does not require permission - java

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

Related

URL intent for Android not firing

I've been learning Java for some time now to develop Android-apps. At this point, I want my website to redirect to my app. This should be possible using an Intent-filter for my website-url. I have used the stackoverflow.com homepage as example.
I use this code in a MainActivity section in the Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nl.example.webitent" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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>
<intent-filter>
<data android:scheme="http" android:host="stackoverflow.com"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</application>
</manifest>
So far, nothing interesting. This is literally a blank activity in a new project with the intent-filter added. I have target-sdk 21 and minimal sdk 16. However, whatever I try, it doesn't fire when I go to stackoverflow.com, neither directly nor through a href.
What is going on, or what am I doing wrong?
When you visit stackoverflow.com in your browser, the intent is not fired. An intent is fired only if the app explicitly does that. This is the case if the app (your browser) is not supposed to open your url scheme. For example mailto is opened in your Mail-App. So you have to create your own URL-scheme like this
<intent-filter>
<data android:scheme="myweb" android:host="stackoverflow.com"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Then a link to myweb://stackoverflow.com would open your app.

Launch activity from google calendar reminders

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.

What is the best way to switch Android Activities?

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

Starting app from the recent menu doesn't start the main activity

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">

Android app not showing in "All Apps"

After some changes I made to my app that I made so it would show the activities in a different order, the app icon no longer appears in the "All Apps" screen on the android device. It does, however, show up on the "Recent" screen. I think it has something to do with a configuration error in my manifest file. I would like the ServerChoiceActivity to be the one represented by the icon, and it's what launches when launch it from the recent screen, but the fact that there is no icon on the "All apps" or "Downloaded" pages confuses me quite a bit.
The application section of my manifest file:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:debuggable="true">
<activity android:name=".ServerChoiceActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<data android:mimeType="image/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".ServerSettingsActivity" android:screenOrientation="portrait" android:label="#string/settings_title">
<intent-filter>
</intent-filter>
</activity>
<activity
android:name=".ImageShareActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="image/*"/>
</intent-filter>
</activity>
<activity
android:screenOrientation="portrait"
android:name=".MultiImageUploadActivity"
android:taskAffinity="test.affinity"
android:label="#string/multiupload_title">
<intent-filter>
</intent-filter>
</activity>
<activity
android:screenOrientation="portrait"
android:taskAffinity="test.affinity"
android:noHistory="true"
android:label="Bucket"
android:name=".BucketActivity">
<intent-filter>
</intent-filter>
</activity>
</application>
Any suggestions? The app works as expected when I launch it, and it was working fine, including showing the icon before I modified the manifest file.
Possibly because you have this in your ServerChoiceActivity intent-filter:
<data android:mimeType="image/*"/>

Categories