I am new to android so I want to change the starting of the application in android manifest but each time the application is stopped cs worked is that we must change the java codes aussie
here is the xml code:
<application
android:icon="#drawable/icon"
android:label="hello">
<activity
android:name=".activity.ServersActivity"
android:label="#string/app_name"
android:launchMode="standard">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.AddServerActivity"
android:label="#string/add_server_label">
<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="irc"/>
</intent-filter>
</activity>
For setting the starting activity, you'll have to add the following Intent Filter to the activity in your AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Please note that you should only add this Intent Filter to one of your Activities. Otherwise, you might experience unexpected behaviours.
There is no way to change the starting activity by code.
Cut this line and paste it inside activity tag to whom you want as starting activity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
For eg: Making AddServerActivity as stating activity
<activity
android:name=".activity.ServersActivity"
android:label="#string/app_name"
android:launchMode="standard">
</activity>
<activity
android:name=".activity.AddServerActivity"
android:label="#string/add_server_label">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="irc"/>
</intent-filter>
</activity>
Related
I made the second page a menu. I want the second page to open when the apk opens. How can I do this with code? I only need a code
Inside your AndroidManifest.xml file you will have something like this:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And you something like this for other acitivities:
<activity
android:name=".SecondActivity" />
What you need to do is just copy/paste that <intent-filter></intent-filter> tags to the SecondActivity, and you get this:
<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and
<activity
android:name=".MainActivity" />
Your code in AndroidManifest.xml file is like following:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"/>
You just have to set the second activity as the launcher of the app, i.e copy/paste <intent-filter> from .MainActivity to .SecondActivity. Like this:
<activity android:name=".MainActivity"/>
<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And that's it! Now the second page opens the app.
I've made an NFC application who can reads NFC tag. It works well. (With all types)
But since yesterday i'm trying to start automatically my app once a NFC tag is maintained against my device.
So i've updated my Manifest :
<activity android:name=".MainActivity" android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="#xml/nfc_tech_filter" />
</activity>
Then, here is my nfc_tech_filter.xml
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.NfcB</tech>
<tech>android.nfc.tech.NfcF</tech>
<tech>android.nfc.tech.NfcV</tech>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NdefFormatable</tech>
<tech>android.nfc.tech.MifareClassic</tech>
<tech>android.nfc.tech.MifareUltralight</tech>
</tech-list>
</resources>
And surprise, it works only when I hold a NFC Type 2 against my device.
I've try with my appartement key (Mifare Classic) and my bank card (IsoDep), and it doesn't launch my app...
I specify that it works when my app is already started.
Any idea?
EDIT :
This is my Manifest right now :
<activity android:name=".MainActivity" android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="#xml/nfc_tech_filter" />
</activity>
Now, when I pass my bank card, it opens the application but doesn't display any result.
Parcelable[] rawMessages =
intent.getParcelableArrayExtra(NfcAdapter.EXTRA_TAG);
rawMessages variable is NULL after that. Same if I put NfcAdapter.EXTRA_NDEF_MESSAGES
ACTION_TAG_DISCOVERED:
This intent is started if no activities handle the ACTION_NDEF_DISCOVERED or ACTION_TECH_DISCOVERED intents.
https://developer.android.com/guide/topics/connectivity/nfc/nfc
You get this Intent when no others has captured it, so there is something wrong in your setup.
You can capture it explicitly like:
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
</intent-filter>
My project is a download manager that open a link to download something.
I want to add this feature that when I use chrome Bower and click in a link , my application suggest to user to use it for opening the link.
I used
<category android:name="android.intent.category.DEFAULT"/>
but there is no effect.
here is my manifest:
<application
android:allowBackup="true"
android:icon="#drawable/gigaget"
android:label="#string/app_name">
<activity
android:name=".ui.main.MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.App.Blue"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="us.shandian.giga.intent.DOWNLOAD"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:mimeType="application/*"
android:host="*"
android:scheme="http"/>
<data
android:mimeType="application/*"
android:host="*"
android:scheme="https"/>
</intent-filter>
</activity>
<activity
android:name=".ui.main.DetailActivity"
android:label="#string/app_name"
android:theme="#style/Theme.App.Blue">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ui.web.BrowserActivity"
android:label="#string/browser"
android:theme="#style/Theme.App.Blue">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity-alias
android:name=".ui.web.BrowserActivity-share"
android:label="#string/open_with_gigaget"
android:targetActivity=".ui.web.BrowserActivity">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/*"/>
</intent-filter>
</activity-alias>
<activity
android:name=".ui.settings.SettingsActivity"
android:label="#string/settings"
android:theme="#style/Theme.App.Blue">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.nononsenseapps.filepicker.FilePickerActivity"
android:label="#string/app_name"
android:theme="#style/Theme.App.Blue">
</activity>
<service
android:name=".service.DownloadManagerService"/>
</application>
with this permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
why I cant see my application as suggested app for download like the other applications.
any help?
You need to tell android that your app should become part of the chooser
In the manifest you have to declare that you have an activity that can handle the relevant content
<manifest ... >
<application ... >
<activity android:name=".MyDownloadActivity" ...>
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:mimeType="*/*"
android:scheme="file" />
</intent-filter>
<intent-filter > <!-- mime only SEND(_TO) -->
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.CATEGORY_OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
I am just learning how to program apps for android, so please bear with me. My original starting activity was called Menu.Java. When I tested the app on my phone, a launcher icon would show up and I could launch the app from it. I decided to add a different Activity for my start up, which is called Login.java. I changed the intents to .MAIN and .LAUNCHER and now my icon won't show up at all. I tried switching it back to the Menu.Java and that worked for a bit (but clicking the icon would load the Menu Activity, and I was wanting the Login Activity loaded), but now that doesn't even work.
EDIT: I have also removed all of the activities from the manifest except the .Login Activity. Did not work.
Here is my Manifest:
`
<application
android:icon="#+drawable/ic_squirrel"
android:label="#string/app_name" >
<activity android:name="com.example.advanced.Login" >
<intent-filter>
<action android:name="com.example.advanced.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.advanced.Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.advanced.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.advanced.Settings"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.advanced.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.advanced.InternalStore"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.advanced.INTERNALSTORE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.advanced.Reading"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.advanced.READING" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.advanced.Passing"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.advanced.PASSING" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.advanced.Numbers"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.advanced.NUMBERS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
`
<activity android:name="com.example.advanced.Login" >
<intent-filter>
<action android:name="com.example.advanced.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Here change the <intent-filter> to
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
When I specify the .main class as the launcher, it crashes on launch. So I made a new activity called launch that will be used to open the .main class. When I specify .launch as the LAUNCHER, the console tells me that no launcher activity was found.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.homework"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
<application android:label="#string/app_name"
android:theme="#style/AppTheme"
android:allowBackup="true">
<activity android:name=".launch"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.LAUNCH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".menu"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".list"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.LIST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Change
<intent-filter>
<action android:name="android.intent.action.LAUNCH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
to
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Well, does the com.my.homework.launch class exist? Does it subclass Activity? Also, the action should still be <action android:name="android.intent.action.MAIN" />.