So I'm updating an app I created a while ago. In the AndroidManifest.xml I have the following (along with an <intent-filter> for android.intent.action.MAIN) inside an <activity>:
<intent-filter android:label="#string/send_label" android:icon="#drawable/icon">
<action android:name="android.intent.action.SEND" />
<data android:mimeType="text/plain" />
</intent-filter>
If I remember correctly, when I first created this app, the above (minus the android:label and android:icon bits) worked; my app would show up in the "Share" menu. A couple weeks ago I noticed a review of my app on the Market saying that it didn't show up when trying to Share stuff. I checked, and sure enough, it wasn't there.
Is the fact that I have two <intent-filter> blocks for one Activity confusing it? Did I break something between then and now, did something change in the Android API, or what's going on here?
Don't you need to specify a category?
(such as <category android:name="android.intent.category.DEFAULT" />
Related
I've developed a simple NFC application that reads and displays the data(NDEF Records) present in the NFC tag. I modified the Manifest file so that whenever a tag gets tapped, my app gets opened.
Now the problem is when I manually open the app and check the multitasking screen, it displays my app name i.e NFCReader but when the app gets opened itself when a tag comes in contact with the device, my app gets opened but when I check the multitasking screen, it doesn't display my app name. Instead it displays NFC Service. What should I do to overcome this issue?
I assume that you have set your activity declaration, in your manifest, to something like this:
<activity
android:name=".packagename.MainActivity"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask"
android:theme="#style/AppTheme.Main">
<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:host="domain.com"
android:scheme="http" />
</intent-filter>
</activity>
I think the answer to your question is the following line of code that you forgot to add:
android:launchMode="singleTask"
I invite you to read about launch modes here and here.
Please note: This answer is based on the use of Reader mode API, otherwise check this answer.
Hope this helps!
Hi I am trying to create an app that accepts files from other applications. I tried this tutorial, http://developer.android.com/training/secure-file-sharing/setup-sharing.html as well as this one, http://code.tutsplus.com/tutorials/android-sdk-receiving-data-from-the-send-intent--mobile-14878 and nothing seems to work.
here is my manifest,
...
<activity
android:name="com.example.activities.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>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/*" />
</intent-filter>
</activity>
...
Yet still for some reason my application won't show up if I try to share files with it from dropbox or anything else. I've tried different mime types, using SEND instead of SEND_MULTIPLE, and starting a clean application project and nothing.
Thanks
EDIT:
Essentially what I want to do is have my app show up in the share menu for all other applications. I managed to get a complete action using... pop up, but this isn't what I'm looking for. Unfortunately all google searches result in the info above.
I believe that I have solved it. for mime type rather than having "application/*" all you need is */*. For some reason, most files are opened as text/plain mime type including excel files. Odd.
I've searched documentation, but I'm missing something obvious. Or am trying to do something backwards.
What I have is the main activity, that's fired from the launcher and widgets. I have a second activity that I'd like to be fired off when a URL of a specific pattern is attempted to be opened. Here's the two activity definitions:
<activity android:name=".activities.MainMapScreen" 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=".activities.ViewDatasheet" android:configChanges="orientation|keyboardHidden" android:label="#string/app_name" android:process=":BMMapsDatasheet">
<meta-data android:name="Main Screen" android:value=".activities.MainMapScreen" />
<intent-filter>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="www.ngs.noaa.gov" android:pathPattern="\\/cgi-bin\\/ds_mark.prl\\?PidBox\\=([a-zA-Z]{2}[0-9]{4})" />
</intent-filter>
</activity>
Like the above, url's aren't intercepted. Even if I have nothing in the data but the scheme and host, I don't get the prompt to select my app.
As a test, I copied the browsable and to the main activity, and when I do that, the icon disappears form the launcher altogether. (And I still get no prompt when trying to hit the URL.
All the examples I find has the in the main activity, not a secondary activity, so.. I'm not sure if I'm missing some flags or such.
Any thoughts would be appreciated. If you want me to post the whole Manifest, let me know.
--Mike.
Edit: After adding #iturki suggestions, there was no change. however - if I also added <category android:name="android.intent.category.OPENABLE" /> to the action to handle the URLs, that worked. None of the examples I saw with the had that category, so I'm not yet sure if it would affect other operations of the activities in my application or not.
Try adding a VIEW action to your second Activity's <intent-filter>:
<action android:name="android.intent.action.VIEW"></action>
And I think you might want to add your Intent to the DEFAULT category too:
<category android:name="android.intent.category.DEFAULT"></category>
I'm not sure if it is important but all the <intent-filter>s have this category.
I know this question is asked and answered many times on SO, but I just couldn't get it to work. Here is my manifest file (I have 3 activities, I'm showing the only one that I want to be displayed when associated):
<activity
android:name=".MyActivity"
android:label="#string/app_name"
android:theme="#style/HoloDarkTheme" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.ACTION_SEND" />
<action android:name="android.intent.action.EXTRA_TEXT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.action.BROWSABLE" />
<category android:name="android.intent.action.DEFAULT" />
<data android:scheme="http" />
<data android:host="example.com" />
</intent-filter>
</activity>
When I launch a browser and go to "example.com", my app isn't launched. Is there something wrong with the above XML?
Not sure if relevant, but this activity uses MediaPlayer to play videos. Also, I'm using SDK version 11.
I figured it out. It's simply a case of typo. Instead of this,
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.action.BROWSABLE" />
<category android:name="android.intent.action.DEFAULT" />
I needed to replace "android.intent.action" with "android.intent.category" in the last two lines:
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
I'm adding this answer here because this thread is one of the top hits when googling "intent filter to launch app from http not working". I suppose the root cause for me could also be considered a typo, but I'm going to call it an "Android documentation defect".
There's a line way toward the bottom of this page that breaks down a URI as:
<scheme>://<host>:<port>/<path>
This breakdown indicates that the "://", ":" and "/" will be added for me so I used the following data in my intent-filter:
<data android:scheme="http" />
<data android:host="my.school.edu" />
<data android:path="thingy" />
I then sent myself an SMS with the following text: "my.school.edu/thingy", which was recognized by my SMS client (Hangouts) as a web address, so it made it clickable. However, clicking on it just gave me a choice of browsers, my app was a no-show.
So I removed the host and the path, and my app launched for any link (or at least every one I tried). I put the host back in and it still worked. Put the path back and we're back to not working. On a whim I decided to prepend a slash to the path:
<data android:path="/thingy" />
...et voilà! There's my app in amongst the browsers! So the error in my view is Android's doc that suggests that the slash is inserted automagically. :) It apparently is not.
More Info: I'm using the HTTP scheme because that's what gets made clickable in SMS and email messages, giving me a free ride to that point.
And note that if you specify a unique host (and path), and the user selects "Always" when choosing your app from the list, future taps on your link will bypass that choice dialog and go straight to your app, which is nice.
Make sure you have the internet permission in your manifest.
I doubt that you can override the http scheme to point back to your app.
I've just spent numerous hours constructing an icon for an Android app I'm working on, but can't get it to show up for the app in the emulator.
I've put it in res/drawable-hdpi, res/drawable-mdpi, res/drawable-ldpi in the respective sizes as defined in http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html
The manifest contains the line:
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="true">
Any ideas as to why it isn't showing up?
I would like to elaborate on the answers of #Britton Pentakill and #arnav bhartiya because I could solve my problem using their answers. I added more actions on my MainActivity because Android Studio was complaining that "App not indexable by Google" and I also wanted it to be indexable.
Wrong AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https"
android:host="siara.cc"
android:pathPrefix="/CrossCalc" />
</intent-filter>
So when I published my app, people could not find my App Icon on their device, no Open button after installing on Play console, even if it did pass review and published on play store (it took 7 days).
Then when I read their answers, I corrected and now I am able to see the icon for opening my app:
Correct:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<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="https"
android:host="siara.cc"
android:pathPrefix="/CrossCalc"/>
</intent-filter>
Make sure the icon is stored with the name icon.png in those folders.
Make sure android has a drawable/icon resource. Check this by looking at your gen/R.java file and seeing public static final int icon = 0x.... in the drawable inner class.
Try cleaning your project build and uninstalling any existing version of your app from your phone/emulator and then reinstall the new version.
Notice Win Myo Htet's comment on the accepted answer. He solved my problem.
Jems since your answer has so much vote, can you add the following
pointer too: Make sure that intent-filter for MAIN and LAUNCHER is not
mixed with other intent-filter. – Win Myo Htet Dec 6 '15 at 5:47
"mixed" being the keyword. I had intent in my AndroidManifest.xml file that was there to prevent all file types from being available in file selects. While it began with the second answer's solution, it contained the extra intent for the file selects. This prevented Android from installing my icons when installing the app. I wanted to post this in case anyone else ran into this issue since Win My Htet's brilliant advice could easily be missed since it is essentially one word "mixed"
Make sure that the Intent of your Launcher Activity is named MAIN i.e,
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Moreover, add the icon to your Drawable folders and then refer it in the application block of Manifest.
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
I had a similar problem recently and I eventually found out there were two causes:
File extension: To stay on the safer side, always stick to .png format. Some other formats actually work on certain devices (e.g using a .jpg icon still showed up on my Infinix note 4 phone) but .png files are guaranteed to work on all devices.
Storage location: Your icon file should be in the drawable folder. Remember to do a double check as to whether your manifest file points to the place you saved your drawable too.
I hope this helps.. Merry coding!
<manifest ...>
<application
android:icon="..."
android:roundIcon="..."/>
</manifest>
In application of manifest of your app there are two attributes, icon & roundicon. one is for debug and another is for release.
For displaying icons you need to replace the #drawable in the theme style and it will work
If you are running on Android 5.0, just add these lines into the onCreate method, inside MainActivity:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true);
It might help in your case.
Add this:
android:roundicon also
In my case after assigning both ic_launcher and ic_launcher_round in all mipmap folders I had to remove the following folder "mipmap-anydpi-v26" in order to show app Icon.
in intent filter tag only action and category are allow not others
tag. if any wrong tag in intent filter tag then you can not open and
see your application in mobile phone.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- <action android:name="android.intent.action.SENDTO" />-->
<!-- <data android:scheme="mailto" />-->
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>