How can i make two activities to one file? - java

I made two activities in Android Studio. One of them is an empty activity the other is a Basic activity. My Problem now is that if I run the app my Smartphone Shows me two files. How can I make this into one file?
[]

It seems both of your activities have the android.intent.category.LAUNCHER
<activity
android:name=".YourActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Related

Android - How to develop Custom Launcher for Home Key?

Since many days Em wondering to find a solution for Android Launcher Application. What we want is to make customized launcher application so we can hide some of the applications from our office devices.
What I did till now?
I used the below Code in Manifest.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
But this doesn't work at all.
add this, you must have to declare category as Home
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />

PreferenceActivity subclass should not be exported in the manifest (ExportedPreferenceActivity)

Android Studio is throwing a lint warning saying
PreferenceActivity subclass com.myapp.app.SettingsActivity should not be
exported in the manifest
Inspection info:Fragment injection gives anyone who can send your
PreferenceActivity an intent the ability to load any fragment, with any
arguments, in your process. Issue id: ExportedPreferenceActivity
I've never actually noticed when this warning started appearing, but I can't find a way to fix it without breaking the activity. SettingsActivity is an AppCompatPreferenceActivity with two PreferenceFragments and gets created after a SplashScreen. I've tried setting android:exported="false" in my Manifest.xml already, but it gives an error because action.VIEW cannot have export turned off.
Relevant Manifest.xml code:
<activity
android:name=".SettingsActivity"
android:label="#string/app_name"
android:theme="#style/SplashScreen">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="#xml/shortcuts" />
</activity>
don't expose it with a launcher (which sounds alike what it complains about):
<category android:name="android.intent.category.LAUNCHER"/>
If possible remove:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
If you can't remove all of it just delete this line:
<action android:name="android.intent.action.VIEW" />

Android Studio code seem to be working alright but I get this run time error

The code doesn't have any errors but it shows this during runtime:
"Error running activity the activity must be exported or contain an intent-filter"
Add this to the activity you want to start inside manifest
<activity android:name=".put your started activity name here"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Add my Android app to the "send via" menu

I use the OSMand Navi app. In there I want to click on a point a hit the Share button. Then there is a list of apps I can send the coordinates to.
I want my app being in that list. I read about it and added an <intent-filter> to my AndroidManifest.xml.
<application
<activity
android:name=".MyMainActivity"
android:label="My App" >
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
But my app is still not on the list. I even tried to reinstall it and restarted my phone.
"Share" is usually implemented via ACTION_SEND, not ACTION_GET_CONTENT.

Android intent data not redirecting mobile phone to application

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

Categories