I have an Android AIR application (developed with Flex SDK 4.5.1) for which I need to block the Home Button, as the app is used by patients in a hospital without supervision, i.e. it is crucial that they cannot leave the app.
It seems that the only way to hijack the Home Button is to be registered as the default launcher, so that your own app gets the focus when home is pressed. This is easily achieved in the manifest, such as:
<activity android:excludeFromRecents="false">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</activity>
Now the problem is: If I do quit the application, the original launcher should be made available to the user and I think the solution would be to just start the original launcher, but how should I do that? The original Android-way of "intents" is not available in AIR and the navigatetoURL() function seems to work only for special URIs, e.g. "market://.." launches the default market app, however, I need to execute an arbitrary application...
Edit: I am referring to a mobile Android App running in this case on an Archos tablet, but it could run on any Android device with AIR installed, such as a typical mobile phone like the HTC desire. With "home button" I am referring to the respective hardware button that allows the user to switch applications (or, to be more exact, to switch to a launcher app that typically shows all the apps as icons to tap on). This "home button" functionality I need to block, as the user should not be able to easily switch to another application.
This is probably a less useful answer but disabling device buttons sounds like something that should be handled at the OS layer and not at the Application layer. Might want to have a custom build of Android for this purpose.
Related
I have successfully set up an intent-filter in my Android app to open the app from the mobile browser based on one of many SO posts on this topic.
However, the problem is that the native app is opening WITHIN the browser, when I rather want it to open OUTSIDE of the browser in a separate app process.
By WITHIN, I mean that when I press the rightmost 'active apps' button to see what is running, I see that my current app is still the browser app, and there is no separate app opened called MyApp. It is as if the browser embeds my native app within itself, and so the browser is executing my app process.
And by OUTSIDE, I mean that I want to be able to see two active apps running after I press the link: (1) the browser app from which I launched (2) my MyApp app.
This is my intent-filter set up in AndroidManifest.xml:
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="myapp" android:host="mypath" />
</intent-filter>
And I link to this from a web page opened in the browser using:
Open app
How can I force the app to open OUTSIDE of the browser? One note is that when the app launches I don't see an 'app chooser' which I've seen for other apps.
By WITHIN, I mean that when I press the rightmost 'active apps' button to see what is running, I see that my current app is still the browser app, and there is no separate app opened called MyApp.
Your activity was launched within the browser's task.
It is as if the browser embeds my native app within itself and itself is executing my app process.
That is not what is happening.
How can I force the app to open OUTSIDE of the browser?
If you mean that you want the activity to appear in a separate task... ideally, that would happen by default. I'm surprised that a browser would not have added FLAG_ACTIVITY_NEW_TASK when it started your activity.
That being said, android:launchMode="singleTask" on your <activity> element should give you the desired behavior.
I am developing an Android Wear biking app. I am trying to enable the "Ok Google, Start cycling" into my app. It works perfectly if I say it to the phone, but not to my Moto360. Also in the Android Wear app, I am unable to choose my app as the default for "Start bike ride" Any suggestions?
This is what I have in my manifest, and it is based off of Google's example.
<intent-filter>
<action android:name="vnd.google.fitness.TRACK" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.google.fitness.activity/biking"/>
</intent-filter>
I searched other similar questions but didn't find a result.
Thanks for your help
Providing a Wear app is a requirement for being listed in the available apps to register for a system provided voice intent on Android Wear and appear in the Android Wear application for choosing as the default for that voice action. Per the Adding Voice Capabilities training, you attach the appropriate <intent-filter> to an activity in your Wear app. One point of note if you aren't ready to provide a full Wear app is this section of the same page:
When users speak the voice action, your app can filter for the intent that is fired to start an activity. If you want to start a service to do something in the background, show an activity as a visual cue and start the service in the activity. Make sure to call finish() when you want to get rid of the visual cue.
In your case, your activity could just display a visual cue that you are launching something (say using a ConfirmationActivity with an OPEN_ON_PHONE_ANIMATION from the Wearable UI library) and then send a message to your phone app, which would then listen for that message using a WearableListenerService and start the bike ride on the phone, posting your notification.
Note that a full Wear app with more customization is going to be expected as many apps, such as Runtastic on Android Wear add quite a few more abilities that augment the standard experience. While not out yet, an upcoming release of Android Wear will be adding offline (i.e., without a phone) GPS support for Android Wear watches that have GPS ability (currently only the not yet released Sony Smartwatch 3) and of course those abilities will require a full Android Wear experience and cannot rely on a phone app (although details have not yet been released).
You need to add a launcher intent-filter to it; then, saying "OK Google, start [app name]" will start the app. The launcher filter is:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I created a basic Android app from the Eclipse wizard. I then added the following intent filter to AndroidManifest.xml, after the existing one. This makes it support a custom "sample://" URL scheme:
<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="sample" />
</intent-filter>
If I run Chrome or the default browser, and click a "sample://" link, it launches my app. However, if I look at the task switcher, my app isn't listed. Instead, Chrome is shown, with my app's screen shot.
Why is this? Can it be fixed? I'm running Android 4.2.2 on a Galaxy Nexus phone.
I notice that if I add android:launchMode="singleInstance" to the activity, it opens in a separate app. But the docs say this is "not recommended for general use". Why not?
The reason why you Activity appears in Recent Apps as Chrome is because it now belongs to the Chrome task, because it was launched from there.
As you noticed android:launchMode="singleInstance" solves your problem, however it is not recommended or discouraged because it would brake the user experience and navigation and how users expect your application to behave.
Fortunately, I think there's a way of specifying Intent flags in your HREF, try something like this:
<A HREF="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=com.example.package/.MyActivity;end" />
in the previous example launchFlags=FLAG_ACTIVITY_NEW_TASK. This flag is generally used by activities that want to present a "launcher" style behavior: they give the user a list of separate things that can be done, which otherwise run completely independently of the activity launching them.
Let me describe you what I want: I want to build a "master app" and set it so that when the phone is powered up, it immediately goes into the master app. The user can never exit this app (this will be used for something like parental control), and he can only launch other apps from within it.
Basically it will be like a "custom desktop".
I must stress out, it is important that this app never exits. As long as the phone is started, this is the only environment that the user has access to.
Now after I explained what I need, I will need your help to tell me what am I looking for. Is this some kind of "default launcher" that I keep hearing about? Or how is this called?
How can I do it?
Thanks
Add this into Manifest.
<receiver
android:name=".Bootupclass"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
</receiver>
Bootupclass
public class Bootupclass extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent intent) {
//write intent here
}
}
I need someone to give me the exact code needed to make the app:
Here Goes,
If you make an app as a launcher app, and if it is the ONLY launcher app within your system, it will of course be started when you switch on your device. And also when you click on the home button, since your app is the only launcher app within the system, the same would be started.
so ,
1) start on bootup 2) be the default action when pressing the home button (the "desktop")
could both be merged into 1.
You mentioned that your phone is rooted, So easiest way to achieve what you require would be to
1.Install your app with just these lines within the manifest. i.e within your first activity. Nothing else is required. (this would make your app as a launcher app)
<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.LAUNCHER" />
</intent-filter>
2.Un-install the default launcher application within your device.
What is being asked in the question body is different from the question title.
Listening to BOOT_COMPLETED will do literally what is requested by title - give control to the application once when device is powered on or restarted.
It is not enough to achieve the real goal - to prevent user from exiting the application and reaching "normal" home screen - once user presses "exit" or "home", he will essentially leave your app. While you can intercept "Exit" button and prevent it from quitting your app, "home" button is not possible to block programmatically.
In order to make and app like parental control and prevent user from reaching unwanted apps you need to implement "custom home screen" or "custom launcher" (which is the same thing).
It is rather large topic, but this seems to be a good starting point: Android - creating custom launcher.
And because author insists on "exact code", to make your app to start instead of a home screen (after boot or pressing "home" button), you need the following in the manifest:
<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>
After install, press "home" button - you will be given a choice of standard launcher or your app. Check "use as default" and select your app - from now on it will start instead of the normal home screen.
Beware, though, that there are few known issues with custom launchers. One is - you have to block access to settings, otherwise user can switch back to default launcher. Also, after your app is updated (i.e. you post new version) user will be asked what home screen to use and can choose default launcher.
I must stress out, it is important that this app never exits This I believe is not possible.
From your requirement it seems that you require a MDM solution. Upwards of Android 2.2 device administration APIs have been available. Check out http://developer.android.com/guide/topics/admin/device-admin.html
The user will have to install your app and allow it to be a Device Administrator. (You can see currently available administrators from Setting -> Location and Security -> Device Administrator). Now as an administrator you can control features on device eg. disallow apps to be uninstalled, prevent installation of specific apps, disallow launch of specific apps. wipe device if security is breached etc. You can also prevent your app from being uninstalled.
There are apps available with such features. I can name Maas360 off the top of my head.
Disclaimer: I haven't tried the device administration apis myself.
I'm developing an android application for my customer. And in that, the User needs to work with that application only. The User should not use any other applications in the Tablet, and my application need to be the default application after i installed the application...
If i shutdown the Tablet my application will be stoped, and if i switch on the tablet means my application will be automatically started.
could i achieve this, any steps to achieve for it..
Help me to fix this, Thanks in Advance
you can start your application while boot is completed using broadcaste but you cant stop the app getting exit while user pressed home button.
You may define your activity as Home, in the manifest file, define as below:
<activity android:name=".YouClassName">
<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>
This way, after install you application, when user long tap the Home button, Android would prompt use to choose which HOME to enter, one is the system default, the other is your activity. At this time, user may also set your activity as default HOME, then when power on, system enter your activity automatically.
If you permission to delete system default launcher (the default home), then your activity becomes to be the unique home.