Launch Intent from URL not working - android

I made a test Android app that I am trying to have launch when the browser hits the URL "blargh://yolo". But it is not working; instead the browser just does a google search.
It is a brand new project created by Eclipse/ADT; the only thing I've edited is the manifest, which is below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testurlscheming"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.testurlscheming.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="blargh" />
</intent-filter>
</activity>
</application>

Some Web browsers, like the AOSP Browser app, treat the address bar differently than it does hyperlinks. Hyperlinks route through a check for who handles ACTION_VIEW for that URL. The address bar is assumed to be something relevant for the Browser app; if it does not recognize it, it conducts a search, just as if you had typed blargh yolo.
Do you know if it works from a redirect?
I would hope so. However, this may be browser-dependent. I would hope that browser makers follow the lead of Browser (and, over time, Chrome), but that's not guaranteed.

Related

can't open android app from menu/ problems with permisions

I have a problem with launching this app through menu. There is no problem when I start it using a different application that has permission. This is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.michael.dangerouslab" >
<uses-permission android:name="course.labs.permissions.DANGEROUS_ACTIVITY_PERM"/>
<permission android:name="course.labs.permissions.DANGEROUS_ACTIVITY_PERM"
android:protectionLevel="dangerous"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:permission="course.labs.permissions.DANGEROUS_ACTIVITY_PERM">
<activity android:name=".DangerDanger" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="course.labs.permissions.DANGEROUS_ACTIVITY"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
Delete both occurrences of android:permission="course.labs.permissions.DANGEROUS_ACTIVITY_PERM" (one in <application>, one in <activity>).
Those say "no third-party app, including the home screen, can do anything with my app, unless they have <uses-permission android:name="course.labs.permissions.DANGEROUS_ACTIVITY_PERM"/> in their manifest". There are roughly zero apps that have such an element, including roughly zero home screen implementations. Hence, you will not be able to launch your app.

Set Android phone for ShowRoom

We, my company, are facing a problem. We have a phone in public use where we can't be always near the phone. It's a show room where public user can test our Android app.
The problem is :
1) Can we block the phone in our app ? we just pin it but it doesn't block the phone. We found some apps the make something like that but not good results
2) A test user just add a security password to lock the phone. So now, we can't unlock the phone. We need to forbid user to add a lock password but we don't want to add one because if the phone is sleeping, a user should be able to unlock it.
**Edit : ** We can't block user from accessing settings
So, is there a solution for that ? like a "ShowRoom" mod ?
If you need more precisions, please ask.
Thanks
First you need to add the following attribute to your activity:
android:launchMode="singleTask"
Then add two categories to the intent filter :
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
The result could look something like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dummy.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.dummy.app.MainActivity"
android:launchMode="singleTask"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
</application>
</manifest>
please read this answer to block exiting app
https://stackoverflow.com/a/16333555/5223973
if you want to use any third party app to lock your app you can use any
android parental control apps

Phoneap 2.9 custom intent on Android not supported from app, only from browser

I've got the following situation with a Phonegap 2.9 Android app:
I declared a custom intent so that the app can be opened from a website.
From within the app, I call an external site I control with a form.
On the page of the external site there's a button that is using the custom intent URL to get back to the app.
This construction works for the iOS version of the app, also using Phonegap.
However, for the Android version the popup of Android is saying it doesn't recognizes the custom URL / intent. When I open my browser and navigate to the same external site and pushes the back button with the custom intent-URL, the app gets started.
After searching hours and hours on stackoverflow and the internet in general, I still can't figure out why it isn't working like expected.
Perhaps good to know is that both the app and the external site are using jQuery Mobile.
The external site is opened from the app using
navigator.app.loadUrl('https://site.external/');
The page is on a HTTPS / SSL location, does this makes any difference?
The manifest looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
package="com.test.app" android:versionName="1.0" android:versionCode="1" android:hardwareAccelerated="true">
<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" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17"/>
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:hardwareAccelerated="true"
android:debuggable="true"
android:allowBackup="false">
<activity android:name="AppName" android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:exported="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="customurl" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<activity
android:name="org.apache.cordova.DroidGap"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter></intent-filter>
</activity>
</application>
</manifest>
The code in the external page is using javascript to prevent possible problems with Google automatic search:
window.location = 'customurl://back/';
The error I receive when pushing the button with the custom intent:
Application Error
The protocol is not supported. (customurl://back/)
So, how do I get the external website which was accessed from the app to start the app again, so the user gets back to the app? The only possibility I can think of after searching for hours and hours is to close the app when the user navigates away to the external site.
I think you might need to set a host in the intent filter also:
<data android:scheme="customurl" />
<data android:host="somewebsite.com" />
Can you check to see if that makes a difference?

Launcher app not in chooser

I'm in the process of making a Launcher app, but I can't get my app to show up in the activity chooser when the home button is pressed. I'm sure I'm just missing something simple, but I can't find it! Here's my manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.espian.jump"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="17" />
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<activity
android:name="JumpActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.NoActionBar"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Try replacing that
<category android:name="android.intent.category.LAUNCHER"/>
with
<category android:name="android.intent.category.DEFAULT"/>
As it says in the android intent filter documentation:
activities that are willing to receive implicit intents must include
"android.intent.category.DEFAULT" in their intent filters
Actually I'd suggest opening that page and searching for that text, and having a little read around it. I think you'll find these categories make a lot more sense if you do. You're specifying that this appears in the launcher instead.

Custom URL scheme Android

Hi custom url scheme is not working for me. Here is my code
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".MainActivity" android:label="#string/app_name"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="http" android:host="jinilabs.test" />
</intent-filter>
</activity>
</application>
when I type the url on the emulator browser - http://jinilabs.test
It is giving me web page not available error.
Is there anything wrong here? Plz let me know
Simply typing the URL into the bar won't do it. Your url needs to be a clickable link on a webpage because the browser method that checks if it's a custom url only fires when a link is clicked; it simply runs url's that are entered in the address bar(and ignores custom urls).
Clicking this link should launch your app as it is now. If it still doesn't work, you may need additional code in your manifest file. Mine looked like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="appcall.thing"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="4" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".AppCallActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="stoneware.app.switcher" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
</application>
</manifest>
Of course, you will have to substitute some of the names in here for names relative to your app. I would also recommend starting your url scheme with something unique rather than http in case the http is confusing the browser. My url scheme, for example was stoneware.app.switcher://
Hopefully this can be of some use to you :)
Add this code to manifest file :
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
and then try.

Categories

Resources