I try to implement launch app from intent filter on ARC using that code :
<activity
android:name=".package.etc.MyActivity"
android:configChanges="mcc|mnc|locale|touchscreen|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|layoutDirection|fontScale"
android:screenOrientation="sensorLandscape"
android:launchMode="singleTask"
android:label="#string/myactivity_name" >
<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="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.pdf" />
<data android:host="*" />
</intent-filter>
</activity>
On Android Tablet, it works. But on Chrome ARC app crashes.
Is Chrome ARC supports that ?
EDIT
I got that crash
Fatal Exception: java.lang.IllegalArgumentException There is no Activity which handles filePath = file:///data/data/org.chromium.arc/external/C1373AC2527597D1C0BC66486DCC787F/Granizo.pdf mimeType=application/pdf
org.chromium.arc.helper.FileHandlerLaunchHelperActivity.buildLaunchIntent (FileHandlerLaunchHelperActivity.java:122)
org.chromium.arc.helper.FileHandlerLaunchHelperActivity.onMessage (FileHandlerLaunchHelperActivity.java:162)
org.chromium.arc.ArcMessageBridge$1.handleMessage (ArcMessageBridge.java:75)
org.chromium.arc.ArcMessageBridgeService$3.run (ArcMessageBridgeService.java:238)
EDIT 2
<activity
android:name="com.package.activities.MyActivity_"
android:configChanges="mcc|mnc|locale|touchscreen|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|layoutDirection|fontScale"
android:screenOrientation="sensorLandscape"
android:launchMode="singleTask"
android:label="#string/myactivity_name" >
<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="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.pdf" />
<data android:host="*" />
</intent-filter>
</activity>
I am going to assume that whatever "ARC file explorer" is refers to some other Android app, packaged via ARC, that is running in your Chrome/ChromeOS environment.
In that case, that app has nothing to do with your app.
It is best to think of ARC as providing separate Android emulators per ARC. Apps in one ARC do not have access to apps in other ARCs, just as apps in one emulator image do not have access to apps in other emulator images (or apps on one device do not have access to apps on a separate device). Hence, your "ARC file explorer", in its own ARC, cannot open a PDF via your app in a separate ARC.
This makes many Android apps fairly useless in the ARC environment, and hopefully is something that will be addressed in the future.
Related
I am developing a parental control app, the goal is, when certain websites are accessed, my app would pop up.
From my research, the way to accomplish this is by adding intent-filter to AndroidManifest.xml
For now my activity looks like this
<activity
android:name=".BlockActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
<data android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
From my understanding, this should intercept any website access because I did not specify any host in data attributes. However, when I open, say, www.google.com, my activity does not start.
I also tried specifying the host like this, but it also did not work.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="www.google.com"/>
<data android:pathPrefix="/"/>
<data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Out of curiosity, I tried another intent-filter with android.intent.action.SEND, and it does trigger for sharing.
FYI, I am testing on a virtual device with API Level 30.
Any insights on my goal of intercepting web browsing are welcome, at this stage I am not even sure if intent-filter is the right way to do it.
I later figured out that the better way of implementing what I'm trying to accomplish is to use AccessibilityService.
I am trying to intercept my own app's URL on android so that the user can open the URL in the app rather than on the browser. (I don't have browser support yet).
This is what I'm doing
<activity android:name=".ui.activity.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.PICK_ACTIVITY" />
<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:host="myapp.com" />
<data android:pathPattern=".*"/>
</intent-filter>
</activity>
For some reason anytime I open myapp.com it still keeps opening in the browser, without giving me the option to open the URL in my app. I am trying this on my emulator with API 16 running on it. I've closed the emulator several times and started it again but still its the same behavior.
To avoid any errors in the URL of my personal app. I even experimented with:
<data android:host="goo.gl" android:scheme="http" />
<data android:host="goo.gl" android:scheme="https" />
The app DOES intercept the above url but ONLY the first time. If I click 'JUST ONCE' in the options presented, I don't get the option ever again until I restart the emulator.
Has anyone gone through this? What might I be doing wrong?
this answer helped me : link to question
if you add the package name to the intent, it will open your app by default
I want my app to handle files called *.mcmidi from browser, email or storage.
I have found that the following intent-filter data element works for android native browser and for android chrome:
<data android:scheme="content" android:mimeType="*/*" android:pathPattern=".*\\.mcmidi" />
and this works for android firefox:
<data android:scheme="file" android:pathPattern=".*\\.mcmidi" />
but if I try to use both then firefox stops being able to open the downloaded files. It seems like firefox doesn't work if any intent-filter specifies a mimeType.
(I've been testing so many combinations of these intent-filters trying to find one that works everywhere)
Does anyone know why firefox is doing this, or any way to work around it?
Ok I worked it out. Chrome and Android browsers use the scheme="content" entry. Firefox uses the scheme="file" entry. If you use the mimeType="*/*" entry then all new email alerts will open the app chooser with my app, which is also no good. Opening file attachments from gmail use scheme="content" but with a different mimeType. File explorer apps generally use scheme="file" with the path extension.
Because they all need different intent-filters, I have used activity-alias to alias my activity three different ways for the different apps, so that they all pass the file content to my app and don't interfere with each other or add themselves as generic file handlers (which is always very irritating). So I have this:
<activity
android:name="my.Activity"
android:label="#string/label1"
android:exported="true" >
<!-- the main intent filter allows chrome and native browsers to open .mcmidi files with my app -->
<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="content" android:mimeType="application/x-mcmidi" android:pathPattern=".*\\.mcmidi" />
</intent-filter>
</activity>
<!-- This alias will cause file explorer apps to open *.mcmidi files with my app -->
<activity-alias
android:name="my.ActivityFileAlias"
android:targetActivity="my.Activity"
android:label="#string/label1"
android:exported="true" >
<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="file" android:pathPattern=".*\\.mcmidi" />
</intent-filter>
</activity-alias>
<!-- This alias will cause gmail and the native mail apps to open *.mcmidi files with my app -->
<activity-alias
android:name="my.ActivityEmailAlias"
android:targetActivity="my.Activity"
android:label="#string/label1"
android:exported="true" >
<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="content" android:mimeType="application/octet-stream" android:pathPattern=".*\\.mcmidi" />
</intent-filter>
</activity-alias>
Which I worked out with a few clues and loads of trial and error. Hope it helps someone.
This seems to be a typical problem and there seems to be a lot of differing behaviour, the problem I'm having though is that my scheme will launch the picker and allow me to choose my app when I hit a link in an email or a note on the device, but if I hit a link on a web page I can't seem to launch the app, don't even get the picker (I'v checked the "defaults" for the two browsers and none are set).
<activity
android:name=".MyActivity"
android:exported="true"
android:enabled="true">
<intent-filter>
<data android:scheme="http" android:host="www.website.com"/>
<data android:scheme="http" android:host="website.com"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
If I use one of my links from an email as below it gives me the chooser, launches my app, all is great, however, hitting the same link in the web browser just launches the page with no chooser. Any suggestions on what the problem might be?
http://www.website.com/share.aspx?id=12345678
Testing on GS2 running ICS 4.0.3 with Chrome and stock browsers.
Add the android:pathPrefix attribute.
<data android:scheme="http" android:host="website.com" android:pathPrefix="/" />
This is how I solved it eventually:
<intent-filter>
<data
android:host="www.website.com"
android:pathPattern=".*\\share.aspx"
android:scheme="http" />
<data
android:host="website.com"
android:pathPattern=".*\\share.aspx"
android:scheme="http" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Also add the following to the Activity tag:
android:exported="true"
The reason there are two addresses is so that the app can pick up canonical domains (with/without www.).
I am trying to associate a file extension with my air app on Android. My goal is to be able to start my app by clicking on a file with a specific file type from either a file manager or mail app. I have found a solution that in theory would work in native, but does not with air somehow.
In the .xml-file for the app, under the tag I have written:
<activity>
<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.BROWSABLE" />
<data android:scheme="file" />
<data android:pathPattern=".*\\.csml" />
<data android:host="*" />
</intent-filter>
</activity>
Does anyone have an idea how this could be solved?
Thanks in advance
Jens
Adobe AIR currently doesn't support intents, here the feature request for it.