Android app dosen't run on device - java

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>

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

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

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>

Run app from Android Studio not working on device, OK on emulator

I have an app which is basically a WebView of a web app I run.
I created the app initially with just one activity (activity_main) that contained the WebView and have been playing around getting that to work as required.
I then decided to add a second activity to do some pre-load checks such as checking for an active network connection etc.
When I added this pre-load-checks activity everything seemed to be going OK but when the app ran in the emulator or on my device (installing the apk or running via AS on the device), my new pre-load-checks activity was the one that started. This was OK as I was tweaking the layout and graphics etc.
I haven't finished writing pre_load_checks yet, so it doesn't yet do all of its checks and doesn't launch the second activity, BUT I need to do some more work on the WebView.
So, I tried switching the app to launch the activity_main activity on launch by changing the Launch Options in Run/Debug Configurations.
Now when I try to run the app on my device it fails. Sometimes it just doesn't start, sometimes I get a message saying that my app has stopped. It works OK in the emulator though.
Note that I hadn't changed anything in activity_main at this point.
When I try to run it, the messages in AS say that the app has been launched on my device - no errors.
I then decided to try renaming the activity_main activity to something more sensible seeing as it was no longer going to be the startup activity. I renamed it to activity_website_view via the refactor->rename option for the layout xml. I also did the same for the associated java file.
After a bit of cleaning up I managed to get things to compile again but somewhere along the line something else odd has happened - now if I go into the Run/Debug Configurations screen my newly renamed activity_website_view shows up under the 'Applications branch of the tree along with app. My pre_load_checks activity doesn't show here.
Similarly, in the toolbar drop down that lets you choose what to run/debug, I have the option to run app or activity_website_view, but not pre_load_checks.
Are these related or is it correct that I have direct access to one of the activities? I can see that I can manually add another 'application' to the list, but I wonder if something I have done along the way has caused my old activty_main to be added automatically and if this is related to why that activity will no longer run on my device but is OK on the emulator.
For info my AndroidManifest.xml is below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nooriginalthought.bluebadgeparking">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".PreLoadChecks"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".websiteViewActivity"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<paction android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
As per my comment above, this was a typo.
The 'p' in front of action shouldn't have been there and was stopping things from launching on my device - BUT very oddly it didn't stop them running in the emulator.

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