Aug 23 | 8:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Aug 23 | 9:00 AM |
Jeffrey G. | has entered the room |
Jeffrey G. |
hi.
|
Mark M. |
hello, Jeffrey!
|
Mark M. |
how can I help you today?
|
Jeffrey G. |
I have my office computer today so I thought I would share some of my intent-related stuff.
|
Aug 23 | 9:05 AM |
Mark M. |
OK
|
Jeffrey G. | |
Jeffrey G. |
here is an idea of some of the things i tried.
|
Mark M. |
those <intent-filter> elements are on <receiver>
|
Mark M. |
that will not work, for responding to startActivity() calls from a Web browser
|
Mark M. |
you need to have <intent-filter> elements on an <activity> to respond to startActivity() calls
|
Mark M. |
and at best a Web browser will use startActivity() when the user clicks on a link
|
Jeffrey G. |
okay, good to know. I tried this as a desperation move. i am going to upload the one i have on my activity next.
|
Jeffrey G. |
but your chatroom is stuck on "finishing upload" so I can't upload another file.
|
Jeffrey G. |
i'll just copy paste.
|
Jeffrey G. |
View paste
|
Jeffrey G. |
this is Xamarin C# but i'm sure you get the idea as far as the intent filter is concerned.
|
Aug 23 | 9:10 AM |
Mark M. |
does Xamarin code-generate the <intent-filter>? I haven't used Xamarin
|
Jeffrey G. |
yeah, it's supposed to.
|
Jeffrey G. |
i'm tempted to just define this in the androidmanifest.xml instead.
|
Jeffrey G. |
just in case something's not working right with how it converts the attributes.
|
Mark M. |
you can't have both pathPrefix and pathPattern
|
Jeffrey G. |
that's how you would do it in java anyway, right? just create your java activity class and then define the intent filter in the xml?
|
Mark M. |
and in this case you don't need either of them, if you want to respond to everything in that domain
|
Jeffrey G. |
okay. I did try them separately before.
|
Jeffrey G. |
okay.
|
Jeffrey G. |
what is the minimum I need?
|
Mark M. |
yes, we put the <intent-filter> elements directly in AndroidManifest.xml
|
Mark M. |
scheme and host
|
Mark M. |
making sure that the scheme matches the scheme that you intend to use (you have http, which will not match https)
|
Mark M. |
if you wanted to stick with the Xamarin-generated manifest, try to find where it is being generated, so you can examine the result and confirm that it matches what you expect
|
Aug 23 | 9:15 AM |
Jeffrey G. |
could i deconstruct the APK file and look for the manifest contained within it?
|
Mark M. |
the easiest solution for that is to install https://play.google.com/store/apps/details?id=c...
|
Jeffrey G. |
i could alternatively see where on my build machine it is combining the AndroidManifest.xml along with the stuff it is generating from the class attributes.
|
Mark M. |
in the "..." menu for your app's entry in the Applications Info app, you will find an option to view the manifest of the installed app
|
Jeffrey G. |
oh, so i could view the manifest directly from an installed app?
|
Jeffrey G. |
nice.
|
Mark M. |
kinda handy... particularly for apps that aren't yours :-)
|
Jeffrey G. |
lol.
|
Jeffrey G. |
is it not possible to modify an existing APK's manifest since the binary is signed or is there a way around that, even if it involves somehow rebuilding it?
|
Jeffrey G. |
i'd like to add BROWSABLE to an existing app that already does what I want.
|
Mark M. |
modding existing apps isn't in my area of expertise
|
Jeffrey G. |
your chat room is still stuck on "finishing upload."
|
Aug 23 | 9:20 AM |
Mark M. |
sorry, must be a Campfire bug
|
Jeffrey G. |
i'm going to try that applications info app.
|
Mark M. |
there are other ways to get at the manifest, but for casual use, Applications Info is the simplest solution
|
Mark M. |
some of the Play Store comments indicate that people encounter crashes, though I haven't had a problem personally
|
Jeffrey G. |
if all is needed is scheme and host, how does android find your app if you don't declare package?
|
Jeffrey G. |
does it just match the host you declare to the host in the clickable link?
|
Mark M. |
oh, sorry, I thought that you were referring only to the non-standard elements that you added
|
Mark M. |
View paste
|
Mark M. |
AutoVerify=false should be the default, so you can probably skip that one too
|
Jeffrey G. |
i would like to know the minimum "stuff" i must add to this intent-filter to at least get it to work locally for test purposes.
|
Jeffrey G. |
i understand there may be more stuff required in production.
|
Mark M. |
oh, whoops, you are using ActionSend
|
Mark M. |
change that to what I assume Xamarin refers to as ActionView
|
Jeffrey G. |
i don't necessarily need to use ActionSend if there are other options.
|
Mark M. |
View paste
|
Mark M. |
(give or take some punctuation, as I am not a C# guy)
|
Jeffrey G. |
will that still popup a chooser dialog?
|
Mark M. |
yes
|
Mark M. |
it should list your app, Web browser(s), and anything else that handles http URLs that include that host and either support all MIME types or support whatever MIME type is associated with your URL
|
Aug 23 | 9:25 AM |
Mark M. |
later, you will probably want to use one of path, pathPrefix, or pathPattern, to limit the URLs that your app claims to handle
|
Mark M. |
see for example: https://github.com/commonsguy/cw-omnibus/blob/v...
|
Jeffrey G. |
it looks like the app's manifest was updated. i see the filter but the name is decorated with a large letter/number combination in front.
|
Jeffrey G. |
i am gong to see if i can copy/paste this from the app to somewhere.
|
Mark M. |
by the name, do you mean android:name?
|
Mark M. |
if so, that may be a Xamarin thing, for how they code-generate Java-style classes from the C# code
|
Aug 23 | 9:30 AM |
Jeffrey G. |
yes.
|
Jeffrey G. |
View paste
|
Jeffrey G. |
at least i can confirm the xamarin c# attributes are getting placed into the manifest.
|
Mark M. |
that lines up with your original IntentFilter that you pasted in
|
Mark M. |
right
|
Aug 23 | 9:35 AM |
Jeffrey G. |
View paste
|
Jeffrey G. |
is there anything else other than the intent filter in the manifest that android needs to make this association work?
|
Mark M. |
your current <intent-filter> is not using VIEW -- it is using SEND
|
Mark M. |
if your objective is to try launching your existing activity with its existing <intent-filter>, replace -a android.intent.action.VIEW with -a android.intent.action.SEND
|
Jeffrey G. |
ahh good point.
|
Jeffrey G. |
how do they differ? do they both cause a chooser to appear?
|
Mark M. |
they're not strictly related
|
Mark M. |
ACTION_SEND is mostly for "share" menu options
|
Jeffrey G. |
if you point to a page in your book I can read about it offline.
|
Mark M. |
and, among other things, it would never have a Uri in the data facet of the Intent
|
Mark M. |
"Intents, IntentFilters" discusses ACTION_SEND
|
Mark M. |
page 799 of Version 8.13 of the book
|
Mark M. |
more importantly, if you want to respond to a click on a link in a browser, that will be ACTION_VIEW, not ACTION_SEND
|
Aug 23 | 9:40 AM |
Jeffrey G. |
ok.
|
Jeffrey G. |
okay, so if I updated it to ACTION_VIEW, remote pattern and prefix, and just use the minimum you suggest, I should be able to get it to work, right?
|
Mark M. |
if nothing else, it should work with the adb shell command
|
Jeffrey G. |
I just want to make sure at this point that the filter is all that is needed from Android to make this connect happen, and that I just need to get the invocation stuff working.
|
Mark M. |
in principle, it should work from a suitable link in Chrome
|
Jeffrey G. |
right using adb shell is going to be my first course of action.
|
Jeffrey G. |
and, just to confirm, only activities can be invoked from chrome and not broadcast receivers, correct?
|
Mark M. |
correct
|
Aug 23 | 9:45 AM |
Jeffrey G. |
i have another topic to ask about. if, for some reason, sending my print data this way doesn't work, is there a way for chrome to save it as a file somewhere that is accessible by another app? could i perhaps write a service that monitors a file folder somewhere for new jobs to print?
|
Mark M. |
it's conceivable that your site could generate a file that Chrome then downloads to a user-specified location
|
Mark M. |
I would not expect JavaScript code to be able to directly write to the filesystem, for security reasons
|
Jeffrey G. |
yeah, that's the part i wasn't sure about
|
Mark M. |
another possibility, depending on your scenario, would be to use WebView instead of relying on standalone Chrome, as you can have much tighter integration between your app code and the Web content with a WebView
|
Aug 23 | 9:50 AM |
Jeffrey G. |
ok.
|
Aug 23 | 10:00 AM |
Mark M. |
OK, that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ soonish
|
Mark M. |
the next chat is Saturday at 4pm US Eastern
|
Mark M. |
have a pleasant day!
|
Jeffrey G. | has left the room |
Mark M. | turned off guest access |