Home Screen App problem - Java for Android App Development

I am in the process of developing an android Home Screen Application, also known as Launcher.
However I ran into a couple of setbacks, setbacks which I will try to describe as best as I can, so hopefully one of you will be able to help me.
My main problem is when I quit my application by setting Android's launcher default as always, I can no longer use my home app, it just doesn't open up again.
This is how my manifest looks like:
<activity
android:name="com.modset.launcher.MainActivity"
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-alias
android:name=".MainActivityAlias"
android:targetActivity="com.modset.launcher.MainActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY"/>
</intent-filter>
</activity-alias>
</activity>
With just this on the manifest whenever I press the HOME button I get the launcher chooser, if I opt for my Launcher everything works just fine, however if I opt for Android's stock launcher I can no longer use my app again.
It either just doesn't open, or if it does I can no longer use it as a Home app again.
I found this extra code which should be able to help me but it doesn't because after using it a message comes up saying "android settings have stopped working".
PackageManager manager = getPackageManager();
ComponentName compName = new ComponentName("com.modset.launcher", "com.modset.launcher.MainActivityAlias");
//ComponentName compName = new ComponentName("<Package Name>", "<Package Name.Alias Name>");
manager.setComponentEnabledSetting(compName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
My biggest problem is that just by adding those lines in the manifest, the first code I mentioned, if I add that, after leaving my app by choosing android stock launcher as default, when i get back to my app it opens just fine however I can't use it as a home app again.
So...
I programatically thought of a work around, by using this code:
Intent selector = new Intent(Intent.ACTION_MAIN);
selector.addCategory(Intent.CATEGORY_HOME);
startActivity(selector);
And it is with this code I have the biggest problem, because when I add this in, the app simply doesn't open up again after exiting it and setting android stock launcher as the default home screen.
Please anyone help me solve this issue.

It will look more tidy if you put your code into
Code:
tags. ;)

Related

[Q] App Chooser not being shown when google browser is the default

I've seen a few other similar threads, but none that both matched my problem and had answers, so sorry if this retreads familiar ground.
I've got a browser and I'm trying to catch the same intents as the google browser. I've even gone so far as to copy and paste them directly from Froyo's browser. They are listed down below for reference. However, when I try to send an intent to create the chooser so the user can select my browser as the default it does not always appear. Here is the code for creating the intent (url-i-want-to-open is an actual url in the code, but I can't post it because I'm a new user):
Code:
Intent anIntent = new Intent("android.intent.action.VIEW",
"url-i-want-to-open");
anIntent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(anIntent);
and the logcat output:
Code:
08-26 14:53:25.698: INFO/ActivityManager(85): Starting activity: Intent {
act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE]
dat=url-i-want-to-open cmp=com.android.browser/.BrowserActivity }
For some reason the intent is automatically resolving to Google's browser unless one of the following is true:
1) I've cleared the defaults from the google browser via application settings,
2) I've installed a third browser, or even just a HelloWorld app with the intent-filters listed below, or
3) I'm running on a platform earlier than 2.2
What is really confusing is #2. It doesn't matter what that third app is. I've used a default hello world with just the first intent-filter and that's enough to trigger something behind the scenes that tells Google it's no longer the only default browser. However, it's not enough in my own app, and the only differences in the two manifests are that mine has a sharedUserId, a couple of extra activities (none of which have intent-filters) and permissions (none of which have anything to do with browsing, in fact HelloWorld doesn't have any permissions at all).
The program flow is: user opens browser, it sees that it's not fully installed and opens another activity, that activity does some stuff (none of which deals with intents) and then checks to see if my browser is the default, if not it fires off the aforementioned intent to create the chooser so the user can set the default.
When I reverse the process (install my app first, then HelloWorld) and have a button in HelloWorld that calls startActivity, the same thing happens: HelloWorld cannot show the chooser unless I've already installed a third app.
Is there a change in froyo that would cause an application to not be able to use startActivity with a generic intent that matches to its own package? Or some other change to the way activities are resolved or installed that broke the way preferred activities are defined? I know that the PackageManager preferred activity functions have changed, but I'm not using them at all.
----- the intent-filters -----
Code:
<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" />
<data android:scheme="about" />
<data android:scheme="javascript" />
</intent-filter>
<!-- For these schemes where any of these particular MIME types
have been supplied, we are a good candidate. -->
<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:scheme="https" />
<data android:scheme="inline" />
<data android:mimeType="text/html"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="application/xhtml+xml"/>
<data android:mimeType="application/vnd.wap.xhtml+xml"/>
</intent-filter>
<!-- We are also the main entry point of the browser. -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
followup: It seems that the OS is remembering preference orders in between installations. So if they ever chose the google browser over mine, the OS will always choose the google browser over mine until either:
1) the google browser's defaults are cleared, or
2) another application is installed that listens to those intents, resetting the need for a chooser

[Q] Help me retain my sanity please! Adding app to "share via" chooser

Hi all. I have literally spent days on this, trawling through git source reps, playing with "Intent Playground", scanning logcat over and over again and I'm tearing my frickin hair out. Perleees, put me out of my misery one way or the other.
Developing an app that does funky stuff with text. Works fine except the last TODO which is to add my app to the "Share via" chooser. Source apps for the text I'm targetting are primarily mail clients.
I've added an intent filter (in fact, tried every combination I can think of) but my app never shows in the chooser.
Code:
<intent-filter>
<action android:name="android.intent.action.SEND" /
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
Here's a logcat fragment showing the chooser being created:
Code:
09-30 20:51:07.964: INFO/ActivityManager(124): Starting activity: Intent { act=android.intent.action.CHOOSER flg=0x10000000 cmp=android/com.android.internal.app.ChooserActivity (has extras) }
09-30 20:51:08.374: INFO/ActivityManager(124): Displayed activity android/com.android.internal.app.ChooserActivity: 381 ms (total 381 ms)
09-30 20:51:30.374: INFO/ActivityManager(124): Starting activity: Intent { act=share typ=text/plain flg=0x13000000 cmp=com.htc.android.mail/.ComposeActivity (has extras) }
As you can see, the share action was initiated in this case from the HTC mail client.
Any ideas? A free copy of my app to anyone who can help out. I know it's not much, but what else can I offer
I don't see a "Share Via" in the gmail client.
There is one in Astro file manager though.
Your app should show up if you long press a .txt file from Astro and click Send.
Hi, thanks for the response.
I should have mentioned it works fine as a send to target but it's the share via chooser I want to extend.
Cheers
Found the solution
Hi folks
Finally found the solution. Very pleased about this because I was just about to offer a $50 reward for one
<intent-filter>
<action android:name="share" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
Click to expand...
Click to collapse
There is NO documentation on this that I can find and I've never seen another intent name in this format. Maybe Google only want partners to be able to add apps to the Share Via choosers?
Anyway, up and running now.
Cheers all

[Q] Home-replacement help

I understand that home-replacement apps are a little (a lot) different than regular app. How exactly would I go about binding (if that's the right word) a view() to the home. When the home button is pressed, I want my home-replacement to be in the list. How would I do that? What specific property or activity() would allow me to do that? Thanks in advance
Code:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
In the android manifest for your specific activity
Thanks
Thank you so much If you would like to know what I'm working on, you can visit my site at futurinnovations.blogspot.com. I would like all the help I can get.
Now that I can bind a gridView to the home, I need to know how to launch applications from that gridView. The gridView is made up of all the application icons, but I don't know how to make it to where the applications are waiting behind their icons. Oh, and can someone help me with making a free-form surface to place applications on that can be freely dragged and dropped? I have attempted to get the code from the example "Making Sense of Multitouch" from the Google Dev Blog to work. I enter in the code (not copy and paste, since I have my own variables and such) exactly like they do, run the application, and all I get is a blank screen. What am I doing wrong?
Sounds to me like you aren't inflating the XML
Sent from my ADR6300 using XDA App
Ummmm...it doesn't have an xml. I'm pretty sure that it is dynamically created. What would I put in the default xml? and how would I inflate it?

NO Accessibility services interface in 4.2?

How can apps like Llama and VoiceNotify be configured to read text now?
Has the UI moved somewhere else?
WibblyW said:
How can apps like Llama and VoiceNotify be configured to read text now?
Has the UI moved somewhere else?
Click to expand...
Click to collapse
Hi,
have you solved the problem?
I think that you must contact the developers and ask them to change some line in the AndroidManifest.xml. With Android 4.2 you must add the attribute 'android: permission' to the accessibility service. I had the same problem in my app AddonsDetector and solved in this way:
Code:
<service
android:name=".service.yourAccessibilityService"
[COLOR="Blue"][B]android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"[/B] [/COLOR]>
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
Nope. Not solved. A 4.2 change i just have to live with
Sent from my Nexus 7 using Tapatalk 2

How to develop an App for Tablets?

Hey XDA-Developers!
I have a big problem with my app, Google Play says that isn't developed for Tablet, I try all, but I don't find the issue. This is my Manifest.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.advanced.rootchecker"
android:versionCode="16"
android:versionName="1.5.4" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="18" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.INTERNET" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_COURSE_LOCATION" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" android:required="false"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:required="false"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" android:required="false"/>
<application
android:icon="@drawable/ic_launcher"
android:theme="@style/Theme.Sherlock"
android:label="@string/app_name" >
<activity
android:label="@string/appname"
android:name=".MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="@string/appname"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:name=".RootCheckerActivity" >
</activity>
<activity
android:label="@string/appname"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:name=".BusyboxCheckerActivity" >
</activity>
<activity
android:label="@string/appname"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:name=".RootDefinitionActivity" >
</activity>
<activity
android:label="@string/acercade"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:name=".AcercaDe" >
</activity>
<activity
android:label="@string/appname"
android:name=".FAQsActivity" >
</activity>
<activity
android:label="@string/appname"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:name=".BusyboxDefinitionActivity" >
</activity>
<activity
android:name="com.adsdk.sdk.banner.InAppWebView"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
android:name="com.adsdk.sdk.video.RichMediaActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:hardwareAccelerated="false" />
<activity
android:name="com.adsdk.sdk.mraid.MraidActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>
Exactly, it says that is developed for more or less 3000 phone models. It isn't developed for Tablets but it works in Nexus 7 and Nexus 10.
This is the application:
https://play.google.com/store/apps/details?id=com.advanced.rootchecker&hl=es
I hope that you can help me. THANKS!
Ah, now I got your question.
It doesn't mean that those users can't install it. It just means that it's not optimized for tablets. They will introduce a new tablet-specific section where apps which are optimized for tablets will be shown.
Read this: http://android-developers.blogspot.ca/2013/10/more-visibility-for-tablet-apps-in.html
And this: http://developer.android.com/distribute/googleplay/quality/tablet.html
Here you can find the tablet section: https://play.google.com/store/apps/collection/tablet_featured
In Play developer console, take a look at the optimisation tips tab on the bottom, they are telling you there what you need to do. I think you need to add at least one 10 inch tablet Screenshot but it might be that the Play Team has to review your app...
Thank's!!
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Did you ever work it out? My game also says that and from what I can read, I think it may be because my game art is all in a folder called "drawable" as it is the same at all resolutions.
Maybe I just need to add some other drawable-hdpi folders with the game icons in them to resolve it. Not sure but was hoping someone else may know, you may have solved it or that my info may help anyone else as this is what I intend to try next update (hopefully later this week).
Burkey said:
Did you ever work it out? My game also says that and from what I can read, I think it may be because my game art is all in a folder called "drawable" as it is the same at all resolutions.
Maybe I just need to add some other drawable-hdpi folders with the game icons in them to resolve it. Not sure but was hoping someone else may know, you may have solved it or that my info may help anyone else as this is what I intend to try next update (hopefully later this week).
Click to expand...
Click to collapse
Have a look at this link: http://developer.android.com/distribute/googleplay/quality/tablet.html
nikwen said:
Have a look at this link: http://developer.android.com/distribute/googleplay/quality/tablet.html
Click to expand...
Click to collapse
Thanks @nikwen, I have read that but it appears a little ambiguous to me. Basically I would want to keep all my game textures in "drawable" for all resolutions and maybe put icon's for home screens in the various resolution specific folders. The article "appears" to just generalise making me wonder if my textures must be there too.. and therefore replicated. I would imagine not but have not tested it myself.
Just thought I would throw it out if anyone else done it this way and if it got past the "tablet optimisation" tip in the publishers control panel.
Burkey said:
Thanks @nikwen, I have read that but it appears a little ambiguous to me. Basically I would want to keep all my game textures in "drawable" for all resolutions and maybe put icon's for home screens in the various resolution specific folders. The article "appears" to just generalise making me wonder if my textures must be there too.. and therefore replicated. I would imagine not but have not tested it myself.
Just thought I would throw it out if anyone else done it this way and if it got past the "tablet optimisation" tip in the publishers control panel.
Click to expand...
Click to collapse
Maybe contact one at Google for that question?
Burkey said:
Thanks @nikwen, I have read that but it appears a little ambiguous to me. Basically I would want to keep all my game textures in "drawable" for all resolutions and maybe put icon's for home screens in the various resolution specific folders. The article "appears" to just generalise making me wonder if my textures must be there too.. and therefore replicated. I would imagine not but have not tested it myself.
Just thought I would throw it out if anyone else done it this way and if it got past the "tablet optimisation" tip in the publishers control panel.
Click to expand...
Click to collapse
You need to add a 7 inch and 10 inch screenshot to make it available for devices with those screen sizes.

Categories

Resources