I've got a model-viewer in my app and I want to create an action button for it (in AR). It was easy to do for iOS,
I did it by adding the parameters in the url like so: .../model.usdz#title=title... etc.
Is there a way to do the same thing for android?
The only docs page I found was this, tried doing it according to this syntax, but it didn't show.
Avocado;
Related
I'm having an issue with Firebase Deep Links on Android.
I have 3 Firebase dynamic links, which are for 3 build flavors of one app, they are like this:
https://my_subdomain.page.link?link=https://my_subdomain.page.link/**app1**?param1=aaa¶m2=bbb&apn=**app1_package_name**
https://my_subdomain.page.link?link=https://my_subdomain.page.link/**app2**?param1=aaa¶m2=bbb&apn=**app2_package_name**
https://my_subdomain.page.link?link=https://my_subdomain.page.link/**app3**?param1=aaa¶m2=bbb&apn=**app3_package_name**
Now what I want when I click on those links is: my corresponding apps
will open directly.
But the actual result is: the links redirect me to the browser first,
then after about 1 second, open the app.
Does anybody know what I'm doing wrong? Please help me.
I've found the answer myself.
Create 3 different URL prefixes on Firebase: subdomain1.page.link, subdomain2.page.link, subdomain3.page.link.
Declare a new intent filter in AndroidManifest, which looks like this:
Also remember to declare a variable named "app_subdomain" with respective values (subdomain1, subdomain2, subdomain3) for each app in build.gradle. For example:
manifestPlaceholders["app_subdomain"] = "subdomain1"
Type yourself these 3 links and use the parameters the way you like:
https://subdomain1.page.link?link=https://my_subdomain.page.link?param1=aaa¶m2=bbb&apn=app1_package_name
https://subdomain2.page.link?link=https://my_subdomain.page.link?param1=aaa¶m2=bbb&apn=app2_package_name
https://subdomain3.page.link?link=https://my_subdomain.page.link/?param1=aaa¶m2=bbb&apn=app3_package_name
That should do it!
hmm, even the android developer page:
Developers
shows this line in the example for notification 'snooze' code:
snoozeIntent.setAction(ACTION_SNOOZE);
but when I try to use it in my Android Studio (3.6.1), it doesn't accept it (or offer it when asking for list of ACTION_ suggestions).
Google is not my friend here, any idea what's wrong on my side?
I think in this case you do not use a predefined 'Intent.ACTION_...'. Instead you create your own constant, being a String, and retrieve this when accepting the intent with 'getAction()'.
For the official link:
https://developer.android.com/reference/android/content/Intent#setAction(java.lang.String)
Although it does not specify such behavior explicitly, it is okay to do this. Unfortunate the guide about 'Notifications' did not expanded on this subject. However, you can see a similar behavior being done with the CHANNEL_ID oa.
As an extra:
If you define your own actions, be sure to include your app's package name as a prefix, as shown in the following example:
Link: https://developer.android.com/guide/components/intents-filters#Building
I need to make all numbers in a string become links.
The expected action when any of these links is clicked is to append the clicked number to an existing string.
I managed to linkify the numbers by using the following code:
Pattern myMatcher = Pattern.compile("[0-9]*");
Linkify.addLinks(myString, myMatcher, null);
How can I access and retrieve the clicked number in this case?
I tried looking in other questions related to Linkify but seems all are describing ways to have an action that opens an activity or open the default app for that link type (email address/web URL/etc.)
Thanks in advance for you help :)
You can Customize Linkify to append any predefiened string(scheme) into that.
Take a look at the following post Android Developer Blogspot (Search for "Custom Linkify")
For clarity I am describing a portion of that post here:
Linkify will automatically append whatever is matched to a scheme that
is supplied to it, so for the sake of argument let's assume we have a
ContentProvider that matches the following content URI:
content://com.google.android.wikinotes.db.wikinotes/wikinotes/WikiWord
The WikiWord part will be appended by Linkify when it finds a match,
so we just need the part before that as our scheme.
Now that we have these two things, we use Linkify to connect them up:
Pattern wikiWordMatcher = Pattern.compile("\\b[A-Z]+[a-z0-9]+[A-Z][A-Za-z0-9]+\\b");
String wikiViewURL = "content://com.google.android.wikinotes.db.wikinotes/wikinotes/";
Linkify.addLinks(noteView, wikiWordMatcher, wikiViewURL);
Linkify can be used multiple times on the same view to add more links,
so using this after the Default Linkify call means that the existing
active links will be maintained and the new WikiWords will be added.
You could define more Linkify actions and keep applying them to the
same TextView if you wanted to.
Now, if we have a WikiWord in the TextView, let's say MyToDoList,
Linkify will turn it into an active link with the content URI:
content://com.google.android.wikinotes.db.wikinotes/wikinotes/MyToDoList
and if you click on it, Android will fire the default intent for that
content URI.
For this to all work, you will need a ContentProvider that understands
that Content URI, and you will need a default activity capable of
doing something with the resulting data. I plan to cover these in
future blog entries (and soon). In fact, the whole Wiki Note Pad
application is currently undergoing some clean up and review, and will
then hopefully be released as a sample application.
Maybe this question has been ask already, but could not find any answer for almost 2hours of internet search.
There is a graphical UI designer wich is coming along with the last android SDK.
Looks pretty cool and well done.
Nevertheless I * cannot find how to attach an event to the control through the graphical editor.
Of course I can add it manually into the xml, but in that case, what's the purpose of having such tool without that function ?
I mean all the other SDK I had in other languages always include that function.
I've also not been able to find doc about how to use this tool. Quite sad...
Thanks
If you want to add a click event handler, select the button (widget) in the GUI that you want to listen for, and look for the property onClick. Enter the name of the method you want to call when the user clicks on that widget, like.. onMyButtonClick
Then add the method to your Activity
public void onMyButtonClick(View v) {
// I heard the button click
}
The GUI builder is getting there, and is not yet as easy to use as the one in XCode, but it's not hard when you get used to it.
i am working in android frameworks.i want to add an item to the existing settings in the android OS.can u plz tell me how to do this?
First read about PreferenceActivity. These group of classes handle user prefs.
Then depending on your task, do something like this.
In case you want to add a live wallpaper or an input method add android:settingsActivity in your Manifest. (Example : here)
Or follow this tutorial