Create a home launcher and call another home launcher - Java for Android App Development

Hi everybody. I'm not sure if this is the right forum for asking this.
I'm developing an app that behaves like a kiosk mode, so I have a variable that indicates if I'm on kiosk mode or "normal mode". I have an Activity registered as category.HOME, which manages what should the app do, depending on the "kiosk mode" variable.
Manifest sample:
Code:
<activity
android:name="com.stuff.kiosklauncher.MainActivity"
android:exported="false"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:stateNotNeeded="true" >
<!-- This tag indicates the initial activity -->
<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>
</activity>
If I press the Home button on my Android phone, my MainActivity is called, and there if we are in kiosk mode, I do nothing, but if I I have the kiosk mode set to off, I look for the preferred launcher (stored in a variable called defaultlauncher), and call it at the onResume() with:
Code:
if(!kioskMode){
Intent startApp = new Intent();
ComponentName component = new ComponentName(
defaultLauncher.getPackageName(),
defaultLauncher.getClassName());
startApp.setComponent(component);
startApp.addCategory(Intent.CATEGORY_HOME);
startApp.setAction(Intent.ACTION_MAIN);
startActivity(startApp);
}
Seems to work ok, but it has some issues, as the "standard" launcher doesn't behave as it should (it doesn't scroll back to the main page when I'm on the desktop, for example... or flicks a little like trying to load my app's layout when pressing continuously the home button). So I'm not sure if I'm doing this right, maybe an Activity shouldn't be the place to lad or not the launcher, but I don't know if I can make a service or a broadcast receiver to be called when the home button is pressed.
I've seen a lot of apps that behave this way (like a launcher on top of another one), but I don't know how they do it.
Again, sorry if this is not the place to seek this kind of help, if that's the case, I'd love to know where should I go. If this is the place, please help. Thanks!

I think that you will not be able to start a service or broadcast receiver.
One idea (I do not know whether it works): Try overriding the onKeyDown and onKeyUp methods for the home button and return true.
Look at this: http://stackoverflow.com/questions/2079691/overriding-the-home-button-how-do-i-get-rid-of-the-choice (especially the second answer)

Thanks, I'll take a look to that!

I had made a kiosk browser app, and it worked perfectly.
My trick was using <activity-alias> tag, as well as some notifications to user mention that, they must select the app as default home launcher if they were in "kiosk" mode.

Moon.lSd said:
I had made a kiosk browser app, and it worked perfectly.
My trick was using <activity-alias> tag, as well as some notifications to user mention that, they must select the app as default home launcher if they were in "kiosk" mode.
Click to expand...
Click to collapse
In your kiosk mode, you had some way to "exit" from it without forcing the user to change the launcher? This would be exactly what I'm trying to achieve, could you provide a little more info? I'm not sure how I could use <activity-alias> here :/
Thanks

pnikosis said:
In your kiosk mode, you had some way to "exit" from it without forcing the user to change the launcher? This would be exactly what I'm trying to achieve, could you provide a little more info? I'm not sure how I could use <activity-alias> here :/
Thanks
Click to expand...
Click to collapse
Well, you can't change an activity intent filter, so you are unable to make a activity from launcher to non-launcher.
But if you are using activity-alias instead of activity, you can disable or enable intent filter of that alias, and thus, by using a shortcut key (like press back 5 times continously), you can exit kiosk mode, disable filter of the alias and default launcher will be automatically called without ask user to do that.
FYI: <activitiy-alias> is a tag in AndroidManifest, just like <activity>, but if <activity> points to a real Activity class, <activity-alias> point to another <activity> tag.

Moon.lSd said:
Well, you can't change an activity intent filter, so you are unable to make a activity from launcher to non-launcher.
But if you are using activity-alias instead of activity, you can disable or enable intent filter of that alias, and thus, by using a shortcut key (like press back 5 times continously), you can exit kiosk mode, disable filter of the alias and default launcher will be automatically called without ask user to do that.
FYI: <activitiy-alias> is a tag in AndroidManifest, just like <activity>, but if <activity> points to a real Activity class, <activity-alias> point to another <activity> tag.
Click to expand...
Click to collapse
Thanks! I'll take a look to that solution, I think I'm getting the idea.

what you can do is get the default launcher as soon as installing the app and store it locally then when the user fires your launcher activity just do what you want to and fire up the home intent directed to the package of previous default launcher this should do it .
If you are doing some heavy duty work then launch a service from the activity and dump your work there this i guess should do it

sak-venom1997 said:
what you can do is get the default launcher as soon as installing the app and store it locally then when the user fires your launcher activity just do what you want to and fire up the home intent directed to the package of previous default launcher this should do it .
If you are doing some heavy duty work then launch a service from the activity and dump your work there this i guess should do it
Click to expand...
Click to collapse
Thanks!
A quick question though, what do you mean by dumping the work in a service? I don't understand completely why and how should I do that.
My first approach was indeed, once I launch my app look for the current default launcher. I even added an option in my app in case the user wants to change the "regular" launcher (looking for the installed packages with the ACTIVITY_HOME filter). The problem is, when I call the intent to the previous launcher, it works ok but not completely. For example, if I'm on the "regular" desktop and I call the home button, it should display the desktop thumbails, or go back to the default desktop, but instead of that, it does nothing (a quick flicker sometimes, I guess because its calling again the activity).

pnikosis said:
Thanks!
A quick question though, what do you mean by dumping the work in a service? I don't understand completely why and how should I do that.
My first approach was indeed, once I launch my app look for the current default launcher. I even added an option in my app in case the user wants to change the "regular" launcher (looking for the installed packages with the ACTIVITY_HOME filter). The problem is, when I call the intent to the previous launcher, it works ok but not completely. For example, if I'm on the "regular" desktop and I call the home button, it should display the desktop thumbails, or go back to the default desktop, but instead of that, it does nothing (a quick flicker sometimes, I guess because its calling again the activity).
Click to expand...
Click to collapse
Working in activities is not proffered as it causes lag on low activity devices
Flickr is probably due the reason you gave that it's being called again and again from the activity
Sent from my GT-S5302 using Tapatalk 2
Hit Thanx Button if i helped you!

sak-venom1997 said:
Working in activities is not proffered as it causes lag on low activity devices
Flickr is probably due the reason you gave that it's being called again and again from the activity
Sent from my GT-S5302 using Tapatalk 2
Hit Thanx Button if i helped you!
Click to expand...
Click to collapse
I see. I think I have an idea on how I can approach this. Thank you all guys, lots of great ideas, you helped me a lot. Sorry I can hit the thanks button only once per message

Related

[Q] customize the home double tap

as a user of power strip, i was extremely frustrated when i realized that the native double-tap function overrides whatever you set power strip to. coming from a droid 1 and cyanogenmod, i knew that there must be a way to take this function over.
after doing a lot of searching i came across this:
http://forum.androidcentral.com/motorola-droid-x/33482-disabling-customizing-double-tap-home.html#post349645
in that post zlandau mentions to edit a line in a database table in /data/data/com.motorola.android.providers.settings/databases/settings.db
line 352 has a value of 'double_tap'.
zlandau mentions to change that value to "<program>/<activity>"
assuming that this method will work for what i want to do [restore double tap to power strip], i'm not sure how to call the app properly.
if someone's able to help me out with this i'm pretty sure it will benefit everyone, as it will finally provide a means to disable/customize the function.
[btw i posted this over at droidforums, but figured i'd throw it up here for a quicker response]
also, once this is figured out, maybe someone could make an app to modify this and throw it on the market. i'm sure it would help a lot of people out. droid 2 and X users alike
after messing around i figured it out, with the help of launcher pro activities.
i didn't realize that the table extended to the right and when i saw the action that was set through the system i realized what i was missing.
i was looking for this
'mobi.intuitit.android.p.powerstrip/mobi.intuitit.android.p.powerstrip.PowerStrip'
however, if i set launcher pro as my default launcher and change the doubletap action to power strip, when i double tap it goes home then launches power strip.
i'm going to try just removing the value all together.
I like where this is headed!
Sent from my DROID2 using XDA App
ecnahc said:
after messing around i figured it out, with the help of launcher pro activities.
i didn't realize that the table extended to the right and when i saw the action that was set through the system i realized what i was missing.
i was looking for this
'mobi.intuitit.android.p.powerstrip/mobi.intuitit.android.p.powerstrip.PowerStrip'
however, if i set launcher pro as my default launcher and change the doubletap action to power strip, when i double tap it goes home then launches power strip.
i'm going to try just removing the value all together.
Click to expand...
Click to collapse
Just set the home key settings to do nothing in launcherpro
MotoBoy said:
Just set the home key settings to do nothing in launcherpro
Click to expand...
Click to collapse
yea that's what i already had it set to.
i guess getting power strip to work properly is another story..
but the instructions i posted above do accomplish setting the double home tap to whateve you want
ecnahc said:
yea that's what i already had it set to.
i guess getting power strip to work properly is another story..
but the instructions i posted above do accomplish setting the double home tap to whateve you want
Click to expand...
Click to collapse
That was a good find. I am thinking of what I want my home double tap to be
The problem is that it still takes you home before launching power strip, when it would be best to have it just launch power strip in the current program you are in... I ran into the same problem with quick desk. I settled on using smart taskbar instead because it can be launched by a swipe action, floating icon, or the notification area. And it launches over your current app window. The developer is very responsive to suggestions as well.
Sent from my DROID2 using Tapatalk
activity name?
I would like the double tap to launch google voice
how do I figure out what the name of the startup activity is?
I know the app is com.google.android.apps.googlevoice and I've guessed some generic activity names like com.google.android.apps.googlevoice.GoogleVoice but no luck so far
you can change the double tap home key by going into settings then applications then it will be the last option. not sure on the camera button

[Q] Does anyone know the search button long press intent?

does anyone know which intent gets broadcast when the search button is long pressed on the Droid X? It isn't the standard android.intent.action.SEARCH_LONG_PRESS that gets sent on most phones...
I believe HomeSmack catches this.. might be worth contacting the dev through the market and asking.
EDIT:
Just noticed dev has a thread for the app here:
http://forum.xda-developers.com/showthread.php?t=827288
Excerpt:
[email protected] said:
HomeSmack allows you to change your default Home or default Long-search app. It's similar to Home Switcher or Home Manager, but uses a method of selecting the default that works well with Android 2.2.
HomeSmack also has some special Motoblur features (that need more testing, hence posting to the Droid X subforum)! On rooted phones it lets you change the double-tap app to any app on your phone (QuickDesk or Powerstrip!) and it lets you install a patched VoiceSearch APK that:
1) Sends the standard android SEARCH_LONG_PRESS intent letting you select any normal long-search app.
2) Still lets you select VoiceSearch as the long_search app or use it normally from Launcher
3) Patches the security flaw noted here (http://www.androidcentral.com/droid-2-bug-allows-anyone-make-calls-passcode-screen)
Click to expand...
Click to collapse

[Q] Shortcut to Recent Call Log

I'm trying to create a shortcut to open up the Recent Call Log versus opening up the dialer. I'm using Apex Launcher and searched through activities, but can't seem to find the one that leads to the Recent Call Log. Any suggestions?
syu78 said:
I'm trying to create a shortcut to open up the Recent Call Log versus opening up the dialer. I'm using Apex Launcher and searched through activities, but can't seem to find the one that leads to the Recent Call Log. Any suggestions?
Click to expand...
Click to collapse
I am using Nova Launcher, but it should be the same:
ecksor said:
I am using Nova Launcher, but it should be the same:
Click to expand...
Click to collapse
Thanks. That activity brings up the recent call log selection screen (where I can check recent calls to delete or edit). I'm looking for the recent call log screen where I can simply swipe to right to dial or left to message.
I can use your activity and simply press bback button after it is launched, but am hoping for a more direct method.
syu78 said:
Thanks. That activity brings up the recent call log selection screen (where I can check recent calls to delete or edit). I'm looking for the recent call log screen where I can simply swipe to right to dial or left to message. .
Click to expand...
Click to collapse
Oh OK.
Open Activities > Contacts (same place as before) and scroll all the way down to 5 green phone icons in a row. Find Phone > RecentCallsListActivity (3rd phone icon from the top), that should do it.
ecksor said:
Oh OK.
Open Activities > Contacts (same place as before) and scroll all the way down to 5 green phone icons in a row. Find Phone > RecentCallsListActivity (3rd phone icon from the top), that should do it.
Click to expand...
Click to collapse
I don't see any activity like that. Not sure if matters, but I'm on a Verizon S5. I appreciate ur help....any suggestions?
syu78 said:
I don't see any activity like that. Not sure if matters, but I'm on a Verizon S5. I appreciate ur help....any suggestions?
Click to expand...
Click to collapse
Hmm... Make sure to look under Activities > Contacts > Phone and not under Activities > Phone.
Carrier shouldn't matter, but a launcher might. You may want to try Nova Launcher just to see if this option is available.
Also, there is always an app for everything: https://play.google.com/store/apps/details?id=se.erikofsweden.erikutil
ecksor said:
Hmm... Make sure to look under Activities > Contacts > Phone and not under Activities > Phone.
Carrier shouldn't matter, but a launcher might. You may want to try Nova Launcher just to see if this option is available.
Also, there is always an app for everything: https://play.google.com/store/apps/details?id=se.erikofsweden.erikutil
Click to expand...
Click to collapse
I don't see the Phone submenu under Activities>Contancts. Tried looking for it with Xshortcuts too.
I've tried that app out, but there's a significant lag opening Recent Calls.
Thanks for you help and info.

Xposed

For anyone wondering, Xposed does work on the Fire TV. I have a module that prevents the "Unknown controller" popup and I'll try to upload the apk soon if anyone is interested.
I was just wondering if the xposed framework would work on this, that's good news!
once we get the amazon crap off of this fireTV, man this thing just SCREAMS potential.
rbox said:
For anyone wondering, Xposed does work on the Fire TV. I have a module that prevents the "Unknown controller" popup and I'll try to upload the apk soon if anyone is interested.
Click to expand...
Click to collapse
Don't tease us!
YES, we want it!
I just want to replace the damn launcher. However once this gets the full treatment and we have a custom ROM available I may have to pic up some extra...
When I get home I'll upload the apk.
As for the launcher, I haven't found the code that launches it yet. But you could try pushing a new launcher to /system/app and see if that allows it to replace the Amazon one.
I just posted How to: Enable installations from "Unknown Sources". Should make installing XPosed modules a lot easier.
So the good news is I was able to create an extremely awful Xposed module that switches the default launcher. I'm going to try to figure out why exactly it insists on using the amazon launcher and maybe create a better way to override it. As for the unknown controller module, I got distracted by the launcher stuff, so I'll see if I can get that uploaded tomorrow.
rbox said:
So the good news is I was able to create an extremely awful Xposed module that switches the default launcher. I'm going to try to figure out why exactly it insists on using the amazon launcher and maybe create a better way to override it. As for the unknown controller module, I got distracted by the launcher stuff, so I'll see if I can get that uploaded tomorrow.
Click to expand...
Click to collapse
I want, I want, me, me, me. Are you going to put it in the Xposed repo?
I really need to look into making Xposed modules.
I don't think I'm going to post it to repo. I really hate all the one-off crap in it. I've looked more into how the launcher is started and I have a better understanding of why the Amazon one always runs. I've spent this night trying to get adbd running as root, so I haven't got much work done on the launcher stuff. Maybe tomorrow night.
Xbmc on the home launcher? Lol
Sent from my Galaxy Nexus using Tapatalk
LiquidXed said:
Xbmc on the home launcher? Lol
Sent from my Galaxy Nexus using Tapatalk
Click to expand...
Click to collapse
I'd rather have XBMC *as* the home launcher (need to edit intents for XBMC). All apps can be accessed from there.
elmerohueso said:
I'd rather have XBMC *as* the home launcher (need to edit intents for XBMC). All apps can be accessed from there.
Click to expand...
Click to collapse
I've thought about that, would probably be the best thing to do since i rarely leave xbmc
As long as XMBC registers an intent for:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
My mod will use it as the launcher.
LiquidXed said:
Xbmc on the home launcher? Lol
Sent from my Galaxy Nexus using Tapatalk
Click to expand...
Click to collapse
I sideloaded Llama and used it to redirect an app (one i don't use called classic tv) to open XBMC when started.
HERE IT IS:
There is a alternative way to invoke XBMC from the FTV Home Screen using Llama. This method uses a “sacrificial” app that you have installed from Amazon that you will use to access XBMC. The app can be anything you have installed but don’t need to use; however, some apps behave better than others (some apps will enter a loop when exiting XBMC). One app that has been tested and works well for this purpose is “Classic TV”.
The advantage of this method is that using the sacrificial app you have Home Screen Access to XBMC and you can exit XBMC to the FTV Home Screen just as you would any other FTV app.
4.1 Prerequisites
Llama side loaded on your FTV.
The app called “Classic TV” from the Amazon app store.
One Llama Event (described below).
4.2 Procedure
Install / side-load Llama.
Install “Classic TV” app from Amazon app store.
Launch Llama (From FireTV - Settings > Applications > Llama > Launch Application).
Go to EVENTS on top menu and click '+' to add a NEW EVENT.
In your NEW EVENT select ADD CONDITION then, from the Menu select 'Active Application' and select 'Choose App’. Scroll through the list of apps until you find “Classic TV” and select this app. Doing this should return you to the Events Menu.
Next, select ADD ACTION and select 'Run Application' from the Menu list. From here, select whatever the name of your XBMC build is. That should create your event. At this point you can also name your event to distinguish it from others.
Now when you start the “Classic TV” app from the Home Screen, it should automatically open XBMC. Feel free to experiment with other apps from the FTV app store. Just be aware that some will loop back and re-start XBMC when you try and exit XBMC to get back to the FTV Home Screen.
amberkalvin said:
I sideloaded Llama and used it to redirect an app (one i don't use called classic tv) to open XBMC when started.
HERE IT IS:
There is a alternative ....
Click to expand...
Click to collapse
Yea, you took this from the xbmc wiki... I think what we'd all like is to completely replace the Amazon launcher. When I hit the 'home' button on the remote, I would like it to take me to XBMC's main screen, not the amazon launcher
craftyguy said:
Yea, you took this from the xbmc wiki... I think what we'd all like is to completely replace the Amazon launcher. When I hit the 'home' button on the remote, I would like it to take me to XBMC's main screen, not the amazon launcher
Click to expand...
Click to collapse
Exactly. I want XBMC to open when I hit Home, but I still want to be able to open FTV Launcher, as an app, when I want to access the store.
---------- Post added at 02:29 PM ---------- Previous post was at 02:22 PM ----------
rbox said:
As long as XMBC registers an intent for:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
My mod will use it as the launcher.
Click to expand...
Click to collapse
Do you need a tester?
rbox said:
As long as XMBC registers an intent for:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
My mod will use it as the launcher.
Click to expand...
Click to collapse
Looking at the manifest.xml for xbmc, it does not register android.intent.category.HOME:
Code:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
We'd need to rebuild xbmc after modifying the manifest
craftyguy said:
Yea, you took this from the xbmc wiki... I think what we'd all like is to completely replace the Amazon launcher. When I hit the 'home' button on the remote, I would like it to take me to XBMC's main screen, not the amazon launcher
Click to expand...
Click to collapse
craftyguy said:
Looking at the manifest.xml for xbmc, it does not register android.intent.category.HOME:
Code:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
We'd need to rebuild xbmc after modifying the manifest
Click to expand...
Click to collapse
I build xbmc for a bunch of purposes and have my 13.1 modified to be launcher.. however pressing the home key never brings up the dialog to switch.. try it with any launcher from the app store.. same thing.. i can share it here if you guys want to try but it makes no diff..
http://www.datafilehost.com/d/b703a710
this is pretty much a straight git pull of 13.1 with manifest edits for launching and fusion/superrepo/unity come built in as sources and there are a few settings defaults in advancedsettings.xml.
mastafunk said:
I build xbmc for a bunch of purposes and have my 13.1 modified to be launcher.. however pressing the home key never brings up the dialog to switch.. try it with any launcher from the app store.. same thing..
Click to expand...
Click to collapse
Interesting, I wonder if Amazon somehow removed the option/ability for setting a default launcher other than their own?

Is there a way to see recent apps and switch between them?

Is there a way to see recently launched apps and switch between them?
This function should be definitely included in default system. So useful!
Can't test it now but try it with long pressing the home button
Huberer said:
Can't test it now but try it with long pressing the home button
Click to expand...
Click to collapse
that goes to the twitch thingy unfortunately.
xd4d3v said:
that goes to the twitch thingy unfortunately.
Click to expand...
Click to collapse
Ok, didn't know. Thank you
I had the same idea but did not work lol.
I am not sure what you are looking for exactly, but the list of apps on the original launcher is always reorganized to show the most recently used apps first. Or are you using a different launcher?
Sent from my SM-N900V using XDA Free mobile app
The best way of doing this is with LMT Launcher using it's Pie feature. Install it, and set up an item as Activity -> System UI -> com.android.systemui.recent.RecentsActivity. This gives you the recent apps, which is normally non-accessible on the shield. You can then add a few others as you see fit. I've added the power menu for example, which gives you the full power off, reboot and sleep options. Not found that anywhere else. All works best with a mouse, so you're best using an alternative launcher like HALauncher. But I suspect most people are doing that anyway given how restricted and awful Leanback is.
It can be downloaded here.
this is like the third or fourth thread about this

Categories

Resources