Include your app when someone takes a screenshot on the device Android - java

when you take a screenshot, and click share, there are some apps that are suggested by the device like whatsapp, facebook,(there is a list), how to include my application to that list? what is the feature called?
the Android device gives you an option of sharing it with
Add to Maps, camera, Facebook, set as profile picture, whatsapp, Hangouts, save to google drive, etc
What is the name of the feature? Could someone, point me to a tutorial about it?

You're looking for Share and View Actions
The documentation should walk you through it fairly well, but the basics are that you need to add an <intent-filter> to one of your Activities in your Manifest file, and declare the type of data that you would like to handle. The example given in the documentation is:
<activity android:name="ShareActivity">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="image/*"/>
</intent-filter>

Related

Two similar intent-filters on Android 10

I have an app which have 2 activities which both can handle android.intent.action.GET_CONTENT action:
<!-- activity 1 -->
<activity android:icon="#drawable/choose_video"
android:label="#string/choose_video"
android:name=".activity.ChooseVideoActivity">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/sample.get.video"/>
<action android:name="android.intent.action.GET_CONTENT"/>
</intent-filter>
</activity>
<!-- activity 2 -->
<activity android:icon="#drawable/record_video"
android:label="#string/record_video"
android:name=".activity.RecordVideoActivity">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/sample.get.video"/>
<action android:name="android.intent.action.GET_CONTENT"/>
</intent-filter>
</activity>
I'm using following code to launch chooser:
Intent sendIntent = new Intent(Intent.ACTION_GET_CONTENT);
sendIntent.setType("application/sample.get.video");
sendIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[]{"video/*"});
startActivityForResult(Intent.createChooser(sendIntent, null), CODE_VIDEO);
On Android versions prior to 10 (api ver. <= 28) everything works OK: if Files app is installed, then it opens with my 2 activities available in Appdrawer menu along with other apps that can handle this action (usually Google Drive is there). If there is no Files app then chooser shows up.
But on Android 10 it behaves differently: it shows only one activity from my app instead of two.
The Question is, does anybody know what exactly was changed in Android 10 that is causing such behavior, and maybe knows a solution to this problem.
Or, alternatively, how to achieve similar behavior with other methods (show 2 icons from my app in Files app's menu while selecting a video)

Why can't I open my app on Play Store?

I have a basic random number generator app that I created using Android Studio. When I run my app using my test device (plugging my phone in) the app runs perfectly fine. I then uploaded this app to the Google Play Store to show my friends and family. When you download the application it says the app was successfully downloaded, but the app wasn't showing up at all.
In trying to open the app I looked on the Google Play Store and instead of seeing the play app button and uninstall button, it only showed the uninstall button.
Image of Play Store
What is wrong with my app that I made?
What file would do this and how could I fix this? (I can post files if needed)
This my first app that I have made and first stackoverflow post. Please give me feedback on how I can solve my problem and how I can better ask for help on this platform. Thanks for your time,
PiNet.
Thank you everybody for helping me solve my issue! Figuring out that playing the app on Android Studio didn't work properly really narrowed down the results from my search and I eventually landed on another stackoverflow post on the same issue.
I currently can't find the post so I will just give you the answer that I found.
In the androidManifest.xml, in my activity. I had all the actions and categories under the same intent filter. After separating them into two intent filters, my issue was solved!
<activity android:name="com.example.random.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>//I only had this intent filter before with the actions & categories above in it
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="android-app" />
</intent-filter>
</activity>
Once again, thank you for your help and your time,
PiNet

Android app dosen't run on device

The app I'm currently developing works perfectly on the simulator.
When plugging in my Android device and press "run", nothing happens on the device.
We have done a lot of code and don’t want to restart everything, we can run different project but not this one. Why ?
On the Emulator it works fine and we got no problems.
The app gets installed on the phone if we look in Settings->program handler but I can’t find it in all programs.
It seems you forgot: "android.intent.category.LAUNCHER" in AndroidManifest, this property add your app (Icon) in list of app.
<activity android:name="com.test.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

is adding actions, data, and category information to android manifest necessary

I was going over some of the Android resources and found something interesting. It says to add intent filters with the different data, category, and actions capable of the Activity to the Android manifest. However i've been able to get my app working without adding those things. Can any one explain if it is required and what adding those intent filters actually does?
It's required that you have one Activity with the following intent-filter IF you want your application to show up on the launcher:
<activity android:name=".YourMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This let's the OS know which Activity to show when your application is started. NOTE: You don't need the above intent-filter if you don't want your application to show up on the launcher (if your application is a widget, for example) (Thanks to Justin Breitfeller).
If you'd like more information on Intent-Filters, check out the developer docs. A common use is allowing other applications to call your application if it can handle certain operations (such as sending an email, launching the camera, etc). If you declare these operations in your AndroidManifest, then your application can be called via Implicit Intents (see the above link).

Creating a Main Activity which DOES NOT appear in the launcher list

I'm looking for a way to have my app launch an activity when opened directly from the Android market, yet not maintain an activity in the launcher menu. I thought that by using the following settings, I would be able to achieve this:
<activity android:name="com.package.test.MyActivity" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
However, it appears that with these settings the Activity seemingly doesn't even exist in the app - it cannot be opened from the market and doesn't appear in the launcher menu. However, by simply adding:
<category android:name="android.intent.category.LAUNCHER" />
the app does both. The problem is I do want the activity to run from the Market, but I don't want it in the launcher menu.
Can anyone enlighten me as to how this can be achieved?
Instead of LAUNCHER, use android.intent.category.INFO. Know that this is not used often, but an example is an add-on package like the Beautiful Widgets animations, where an informational screen beyond the Market listing is useful after the app is installed, but no harm will be done if the user never discovers this activity.
(See also this question.)

Categories