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.
Related
I have created an android app using android studio. When i run my code on the IDE, its runs as expected on the connected phone. The problem is, it does not leave behind an icon on my phone to use it next time. I will again have to run from android studio to use the app. This was fine initially, i don't realize what made the icon vanish. The app is also present in the settings.
When i go to
Settings->apps
i can very well find my app over there. It is not disabled. I tried uninstalling the app and trying again. It still doesn't give me the icon.
I cleared defaults, forced closed and tried everything possible. Nothing is helping me.
Please help.
My AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".TwitterLogin"
android:label="#string/title_activity_twitter_login" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.chillumapp.com"
android:pathPrefix="/chillum"
android:scheme="http" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".NextActivity"
android:label="#string/title_activity_next" >
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="b1fe9f0c7d80c3c24879d634b199f2d0e474b4ba" />
<activity
android:name=".WebViewActivity"
android:label="#string/title_activity_web_view" >
</activity>
</application>
</manifest>
You should specify a different for every intent that can launch your app. So one for the BROWSER category with your url data, and one for the LAUNCHER category.
From the App Manifest Guide.
Components advertise their capabilities — the kinds of intents they can respond to — through intent filters. Since the Android system must learn which intents a component can handle before it launches the component, intent filters are specified in the manifest as elements. A component may have any number of filters, each one describing a different capability.
Your code would become something like:
<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:host="www.chillumapp.com"
android:pathPrefix="/chillum"
android:scheme="http" />
</intent-filter>
I am trying to set up a mobile website that opens my mobile app when a link is clicked in the Android browser. To accomplish this task, I added an intent filter to AndroidManifest.xml, as seen in the code below:
<activity android:name=".MyAppActivity" android:label="#string/app_name" android:theme="#style/Theme.Titanium" android:configChanges="keyboardHidden|orientation" android:alwaysRetainTaskState="true" android:launchMode="singleInstance">
<intent-filter>
<data android:scheme="myapp" android:host="app"/>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
The link itself in the browser works great, and I'm easily able to gather parameters when the app is first opened using Ti.Android.currentActivity. The problem comes when the app is already open, but a user clicks the link to open it from within the mobile browser. When my app opens, instead of resuming where I left off before, I simply see the splashscreen. This goes both ways: If I opened the app first from the mobile browser, then tried to resume it later from the Android homescreen or app drawer, I only see the splash screen. Per tips I saw on other places of the internet, I tried adding the code below to AndroidManifest.xml (as seen above):
android:alwaysRetainTaskState="true" android:launchMode="singleInstance"
This however, appears to have no effect on anything, and the same problem persists. What am I missing here? Any help would be greatly appreciated.
The way i have done was like this
<android xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18"/>
<manifest android:installLocation="preferExternal"
android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application android:label="App Name" android:largeHeap="true">
<activity
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="#string/app_name"
android:launchMode="singleTop"
android:name=".mainActivity" android:theme="#style/Theme.Titanium">
<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="schemaname"/>
</intent-filter>
</activity>
</application>
</manifest>
</android>
and its working fine for me . for Android 4.XX
I am trying to allow a URI to be registered to open up with my app. Like the PatternRepository on the Blackberry and the CFBundleURLName/CFBundleURLSchemes on the iPhone. How do I achieve the same results on the Android?
The system will be sending emails with the following link: myapp://myapp.mycompany.com/index/customerId/12345. The idea is that the user should be able to click on the link to open up the customer activity in the application.
I've tried numerous suggestions from other SO posts but I cannot get the OS to recognize the pattern and open my app.
On The Gmail app it looks like this: myapp://myapp.mycompany.com/index/customerId/12345. It recognizes and underlines the myapp.mycompany.com/index/customerId/12345 portion of the link and it opens it in a browser. The myapp:// part is not linkified.
The standard mail application treats the entire link as plain text.
What am I missing here?
PS: I've already looked at
How to implement my very own URI scheme on Android
and How to register some URL namespace (myapp://app.start/) for accessing your program by calling a URL in browser in Android OS?
The Manifest:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="2"
android:versionName="0.0.8"
package="com.mycompany.myapp.client.android">
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="7"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:label="#string/app_name"
android:name="myappApplication"
android:icon="#drawable/ic_icon_myapp"
android:debuggable="true">
<activity
android:label="My App"
android:name=".gui.activity.LoginActivity"
label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".gui.activity.CustomerDetailActivity" >
<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="myapp"/>
</intent-filter>
</activity>
<activity android:name=".gui.activity.CustomerDetailActivity"/>
<activity android:name=".gui.activity.CustomerImageViewerActivity" />
<activity android:name=".gui.activity.CustomerListActivity" android:configChanges="orientation|keyboardHidden"/>
<activity android:name=".gui.activity.HomeActivity" android:configChanges="orientation|keyboardHidden"/>
<activity android:name=".gui.activity.AboutActivity" android:configChanges="orientation|keyboardHidden"/>
<activity android:name=".gui.activity.AccountActivity" android:configChanges="orientation|keyboardHidden" />
</application>
</manifest>
The final solution was a hacky workaround to cover all bases. The email now also contains an attachment with an extension that is registered to open with the app.
AndroidManifest.xml :
<activity android:name=".gui.activity.CustomerDetailActivity" >
<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="https"
android:host="myapp.mycompany.com" />
</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="myapp"
android:host="myapp.mycompany.com" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/myapp" />
</intent-filter>
</activity>
When I was working on OAuth with Google Calendar, I had to add this filter to the Activity I wanted to receive the callback:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="yourapp" android:host="goog"></data>
</intent-filter>
The when the browser invoked the yourapp://goog URL, it would return to my Activity.
You can get around the issue of GMail not linking non-standard protocols by using a standard HTTP URL with a 302 redirect. You could either set it up on your website's webserver or application server, or for the quick and dirty test you could use a URL shortener like http://bit.ly.
This is solution for me. Thanks #DanO
<intent-filter>
<data android:scheme="yourcustomname"/>
<data android:host="*"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Have you dried adding a category to your intent-filter:
<category android:name="android.intent.category.BROWSABLE" />
You could always try sending your emails using HTML and then use an <a> tag around to create the URL. I don't think there is a way to change the way the Gmail or Mail parse their text, since they probably use the Linkify class.
Another option would be use use http:// and then just parse for a specific custom subdomain which would provide your users with the option to open in a browser or your application.
I just ran into this also, but for standard http: scheme urls. Gmail doesn't appear to add any categories to the Intent. Now I check for BROWSABLE, but I also include a check for !intent.hasCategories() and allow that to go through as well.
I have a main activity. From it, I am calling 2 other sub activities called FacebookLogin and Twitterlogin. I am using the following code in AndroidManufest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examples.Kikin" android:versionCode="1"
android:versionName="1.0">
<!-- THIS IS THE BEGINNING OF SHARING LINKS FROM THE BROWSER -->
<application android:icon="#drawable/kikinlogo"
android:label="#string/app_name" android:debuggable="true">
<activity android:name=".Kikin" 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 android:label="#string/app_name">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:name=".FacebookLogin" android:label="#string/app_name">
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<!-- <data android:mimeType="image/png" /> -->
</intent-filter>
</activity>
<activity android:name=".TwitterLogin" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="yourapp" android:host="twitt"></data>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
Am i doing it right?
Should i nest the FacebookLogin and TwitterLogin activities in the main activity?
The aforesaid 2 classes are in the package com.examples..
* is the same wherever used.
The labels for your FacebookLogin and TwitterLogin appear to be missing an '#' - change them to android:label="#string/app_name"
There's no such thing as a "subactvity". Just because you call one activity from another doesn't mean it's a "subactivity".
You can't nest activity tags in the manifest and you'd probably get a compile error if you tried.
in manifest you can set only one activity in launcher tag okay android does support multiple launcher activity.
The manifest you posted looked fine.
But regarding your comment about the error message "Have you declared this activity in AndroidManifest.xml?", you need to check carefully the package and class name of the Activity you are trying to launch, and make sure that it matches the <activity android:name> you have written in the manifest.
All the info you need should be in the error message.
Don't nest activity declarations, just have them all as elements in your application element:
<manifest ...
<application ...
<activity ...
</activity>
<activity ...
</activity>
<activity ...
</activity>
</application>
</manifest>
The sample you posted here (indenting aside) looks fine.
Maybe you have tested it already but just try declaring your activities with the full path (although you have already declared it in the package tag). So, instead of using
<activity android:name=".TwitterLogin" />
use
<activity android:name="com.examples.Kikin.TwitterLogin" />
Sometimes problems are caused because of that.
I know this is an old thread but Im having the same problem and in my case specifying full package name doesnt help. Have you already found a solution? I`m really interested in knowing how to avoid this error.
I would like to know if we can have a link in a SMS that would be handle by my application. For example a link which would look like myapp://blabla. And by clicking on it myapp would be open with the link as an argument.
This question also refers to email, either from a file with a special extension or a link like in the SMS.
Thanks a lot for your help.
Edit 31/01
Actually, I did what Greg suggested it but it doesn't work. Such a link (myapp://blabla) is not clickable in a SMS/email...When I replace myapp with http as a scheme, it works (Android asks me wether it should open the link with myapp or the browser). But myapp://blabla isn't clickable with myapp as a scheme.
Here is my code:
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".myapp"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<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.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="myapp" android:host="blabla" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"></activity>
<activity android:name=".SettingsActivity"></activity>
</application>
Yep you can with an intent filter.
Basically in your android Manifest, choose an activity that you want to be the one that handles the given url.
<activity android:name=".myactivies.MyActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="myapp" android:host="blabla" />
</intent-filter>
</activity>
Then inside your activity you can get the url by calling getData() on the intent.