Not opening share activity - android

I want to receive data from other apps. I have ShareActivity class and added it to AndroidManifest but i can't show my app to the share apps list. Please help.
<activity
android:name=".share.ShareActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:noHistory="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />
<data android:mimeType="image/*" />
<data android:mimeType="text/plain" />
<data android:mimeType="video/*" />
<data
android:host="www.youtube.com"
android:mimeType="text/*"
android:scheme="https" />
</intent-filter>
</activity>
=============================== EDIT =======================================
Only i removed this line and it worked:
<data
android:host="www.youtube.com"
android:mimeType="text/*"
android:scheme="https" />

specifies Your intent-filter like below code
Try this
<activity android:name=".share.ShareActivity"
android:name=".share.ShareActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:noHistory="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
for information read here

Related

Element intent-filter is not allowed here-Android Studio

I was adding some text editor utilities to my application. Everything was complete and the last was to write the activities to the manifest. This requires some intent-filters for the the main text editor activity but Android Studio says "Element intent-filter is not allowed here" and now i can't sync nor build the app because of this problem. Here's the part of the code that contains the activity:
<activity
android:name=".GrimEditorActivity"
android:label="#string/GrimAppName"
android:launchMode="singleTop"
android:configChanges="locale" />
<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:mimeType="text/plain" />
<data android:scheme="file" />
<data android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.txt" />
<data android:pathPattern=".*\\.html" />
<data android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable"/>
NOTE: This is not the main activity nor the launcher of this app, its an utility builtin. If there's a misunderstanding or help possible, please respond to the topic.
Because your activity tag is being ended only at start. You need to remove closing /.
<activity
android:name=".GrimEditorActivity"
android:label="#string/GrimAppName"
android:launchMode="singleTop"
android:configChanges="locale"> //You have end tag here.
your intent filters..
</activity> // close activity tag.
You also need to add ending </activity>as shown.
Try This One:
<activity
android:name=".GrimEditorActivity"
android:label="#string/GrimAppName"
android:launchMode="singleTop"
android:configChanges="locale">
<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:mimeType="text/plain" />
<data android:scheme="file" />
<data android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.txt" />
<data android:pathPattern=".*\\.html" />
<data android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable"/>
</activity>

How to show my app as a downloader

How can i register my app as a downloader as shown in the screenshot below. I have tried adding below code in my manifest but didn't work.
<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="http" />
<data android:scheme="https" />
</intent-filter>
here is my activity in manifest:
<activity
android:name=".modules.downloader.home.HomeActivity"
android:theme="#style/AppTheme.NoActionBar">
<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" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
You need to provide MIME type as well. If you support all types of files, then you can give <data android:mimeType="*/*" />
<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:mimeType="*/*" android:scheme="http" />
<data android:mimeType="*/*" android:scheme="https" />
</intent-filter>

Control multiple activity intents in android

I am trying to open my app depending on the url that is entered but in some cases it tries to execute several activities at the same time, is there any way to restrict this so that the MainAction does not execute when trying to execute another?, basically my manifest goes like this
Main Activity
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="www.test.com" />
<data android:host="m.test.com" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="home"
android:scheme="testapp" />
</intent-filter>
</activity>
Detail Activity
<activity
android:name=".DetailActivity"
android:label="#string/title_activity_detail"
android:launchMode="singleInstance"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="detail"
android:scheme="testapp" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="www.test.com" />
<data android:host="m.test.com" />
<data android:pathPrefix="/homes"/>
</intent-filter>
</activity>
the problem is that when i try to open a link like "http://www.test.com/homes" this happens:
Your DetailActivity should be declared as shown below, no intent filter is needed.
<activity
android:name=".DetailActivity"
android:label="#string/title_activity_detail"
android:theme="#style/AppTheme.NoActionBar">
</activity>
The thing that matters is the launchMode for the MainActivity
You should read that : https://developer.android.com/guide/topics/manifest/activity-element.html#lmode

How to Show App's Name in "Completing action using" menu?

I tried to use implicit intent to open my android app. It almost works, my app icon really appears in the menu "completing action with". However, instead of showing the real app name, as all the other applications do, the name appeared below the icon of my app is the package name, like "com.example.xxx", which is not quite user friendly. Where can I define this name?
Here's the code I used in the manifest xml:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.testImplicitIntent.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.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:mimeType="application/txt" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
</activity>
</application>
There is some problem with your #string#/app_name
Inside the intent filter in each intent filter give the android label
<activity
android:name="com.example.testImplicitIntent.MainActivity"
android:label="#string/app_name" >
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:mimeType="application/txt" />
</intent-filter android:label="#string/app_name" >>
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
</activity>

How can I set an icon for my custom mimetype

I have created a new mimetype, it works very well with file browser, and it open my activity, but it displayed as unknown icon on file browser, I use ASTRO file browser.
I have added an icon for the intent, but it still appears as unknown icon
this is my code
<activity android:name=".SharedActivity" android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter android:icon="#drawable/icon" android:label="swv">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:icon="#drawable/icon" android:label="swv">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.swv" />
</intent-filter>
<intent-filter android:icon="#drawable/icon" android:label="swv">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:mimeType="application/swv" />
</intent-filter>
<intent-filter android:icon="#drawable/icon" android:label="swv">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.swv" />
</intent-filter>
</activity>
Try putting the icon on the <activity> element, instead of (or in addition to) on the <intent-filter> elements.

Categories

Resources