I am checking below google sample code for test Deep-linking with Navigation.
Navigation with Deep linking Basic Sample
It works well. But in navigation.xml file I don't want to add uri directly , I want to use strings.xml file for same.
Not this :
<deepLink app:uri="www.example.com/user/{userName}" />
but , Want to do like this ,
<deepLink app:uri="#string/profile_url" />
the reason is that, if there is any changes in URL then I just have to go in strings.xml file and replace relative things.
Let me know if you have better idea about it or any better optimized solution.
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!
I want to implement the android.intent.action.SEND as per the developers tutorial with the navigation component.
But when making deep links in the navigation.xml it requires a Uri with the below error message:
Navigation XML document element must contain a app:uri
attribute.
I am using Android Studio 4.1.3 and I do have the option to choose an action. But it just doesn't work without uri.
The docs are leaving some basic questions open:
How to get the intent params like Intent.EXTRA_TEXT
How to provide category and 'data'?
How to provide multiple actions/categories/datas?
I have an android app that using com.google.android.gms.actions.SEARCH_ACTION
to search a phrase on my app using search for PHRASE on APP_NAME, but now I want use custom voice command like APP_NAME PHRASE to open my app and pass that phrase using google assistant.
So is it possible to implement this feature?
I have tried with https://github.com/actions-on-google/appactions-fitness-kotlin to get deep idea about actually how action intent works and found that it may be possible using deep linking.
Here in this example in actions.xml file one action actions.intent.GET_EXERCISE_OBSERVATION implemented as you can see below code.
<action intentName="actions.intent.GET_EXERCISE_OBSERVATION">
<fulfillment
fulfillmentMode="actions.fulfillment.SLICE"
urlTemplate="content://com.devrel.android.fitactions.FitSliceProvider/stats{?exerciseType}">
<parameter-mapping
entityMatchRequired="true"
intentParameter="exerciseObservation.aboutExercise.name"
required="true"
urlParameter="exerciseType" />
</fulfillment>
<fulfillment
fulfillmentMode="actions.fulfillment.DEEPLINK"
urlTemplate="https://fit-actions.firebaseapp.com/stats" />
<parameter name="exerciseObservation.aboutExercise.name">
<entity-set-reference entitySetId="ExerciseEntitySet" />
</parameter>
</action>
<!-- Defines an entity set with our supported entities -->
<entity-set entitySetId="ExerciseEntitySet">
<entity
name="#string/activity_running"
alternateName="#array/runningSynonyms"
identifier="RUNNING" />
<entity
name="#string/activity_walking"
alternateName="#array/walkingSynonyms"
identifier="WALKING" />
<entity
name="#string/activity_cycling"
alternateName="#array/cyclingSynonyms"
identifier="CYCLING" />
</entity-set>
But now I have some questions regarding this code.
How urlTemplate content://com.devrel.android.fitactions.FitSliceProvider/stats{?exerciseType} for actions.fulfillment.SLICE is generated?
Can exerciseObservation.aboutExercise.name have any custom value rather then defined in entity-set ?
How urlTemplate https://fit-actions.firebaseapp.com/stats for actions.fulfillment.DEEPLINK is generated?
After implementing this I think actions.intent.OPEN_APP_FEATURE will be helpful with the help of DEEPLINK fulfillment.
So is it possible to implement this using actions.intent.OPEN_APP_FEATURE"?
How urlTemplate content://com.devrel.android.fitactions.FitSliceProvider/stats{?exerciseType}
for actions.fulfillment.SLICE is generated?
The urlTemplate value (whether fulfilling via slice or deep link) is fully up to you to define. In the case of a deep link, this is the URL the system will call to open up your app. In the case of a Slice, this is the contentUri the system will call to render the Slice. The parameters inside the {} will be expanded with values at runtime. To get a better understanding of how that works, see the docs here and here or the Google I/O 2019 session.
Can exerciseObservation.aboutExercise.name have any custom value rather then defined in entity-set ?
I'm not exactly sure what you mean here but let me try and give more detail. The param name of exerciseObservation.aboutExercise.name is set for each Assistant Intent can cannot be changed. These values are listed in the documentation (example). The actual values of the parameters (that are populated by the user's query at runtime) are dynamic and will change based on the user's query and the Assistant Intent. For each Assistant Intent, you can refer to the docs to see what the possible values can be. In some cases they are from a set list of values (like for GET_EXERCISE_OBSERVATION), for others it could be a free form value based on the user's input, and for others still you can optionally extend the values using inline inventory (this is what you use <entity-set> for in your example).
How urlTemplate https://fit-actions.firebaseapp.com/stats for
actions.fulfillment.DEEPLINK is generated?
As per #1, the value of urlTemplate is totally up to you to configure. It can be any Android Intent URI. The system will call this Uri to start up your app/Activity.
After implementing this I think
actions.intent.OPEN_APP_FEATURE will be helpful with the
help of DEEPLINK fulfillment.
So is it possible to implement this using
actions.intent.OPEN_APP_FEATURE"?
OPEN_APP_FEATURE is just another Assistant Intent that allows a generic call into a feature of your app. The docs were recently updated with some example queries. Eg.
Open Youtube history
This example will open the app named "YouTube" and pass the feature name "history" to the app to handle.
Open Example App Example feature
This example will open the app named "Example App" and pass the feature name "Example feature" to the app to handle.
I'm trying to create a cross platform app using Xamarin.Forms. As far as I know, the UI will be created from the code and the .axml file will be generated automatically.
Can I modify the .axml file to edit the UI? I tried editing but all that comes up is what is written in the code. ie: hello forms
UPDATE
public static Page GetMainPage ()
{
return new simplerow ();
}
In Xamarin.Forms you can create your pages from markup definitions that are shared across all platforms.
Typically you will write all your content pages using Xamarin.Forms, however you can mix-and-match native pages into an application should you so wish.
These shared common pages, written in Xamarin.Forms, will reside maybe in a PCL project, or a Shared Project so these can then be re-used in the platform-specific projects, each targeting a specific platform OS.
You can write these common pages, either in code, or in XAML. You can even choose to write some pages one way, and some the other if you so choose.
A Xamarin.Forms page is processed at runtime through the interpretation of the page composition that has been created.
Each control that is specified on a page, has its own platform specific renderer, behind the scenes, that will produce output that is targetted to that OS.
When writing Xamarin.Forms pages, for-the-most, you will start to learn a new way of creating pages that is abstracted from the intricacies of creating mobile applications on each different platform OS.
There is therefore no editable .axml that is generated etc as you will write your pages using Xamarin.Forms markup and controls, and even your own or other custom-controls to produce your own application pages.
The following link shows some examples of how to write XAML pages.
The following link shows some examples of how to write from code-behind pages.
Along with the previous answer re: .xaml instead of .axml, you need to remember to change the startup code in app.cs to use your new .xaml form. Replace the "new ContentPage {...};" with "new MyForm();" (where "MyForm" is the name of your shiny new XAML form).
EDIT: Downloaded the project from the dropbox link. Comments below...
I see several issues here. I think you may need to go through the walkthroughs and sample applications provided by Xamarin to get up to speed with the concepts behind XF apps.
First, you are trying to use an Activity as your application's page. In a Xamarin Forms app, it must be a View of some sort, not a platform-specific visual such as Activity.
Second, remove the "test.xml" file from your Android project's Resources/layout folder; while XAML files are indeed XML, they have an 1) have a file extension of .xaml and 2) belong in the shared project.
Here's what you need to do to get your project working: (I'm assuming you're using VS here, under Xamarin Studio, it's slightly different.)
Right-click your "testforms" shared project
Click Add from the context menu and select "New Item"
In the dialog that appears, select "Forms XAML Page" and in the Name area enter a name (such as "MyForm")
(If you're using XS, choose "New File" and "Forms ContentPage")
This will add two files to your project: a XAML file containing your layout (e.g.: MyForm.xaml), and a code-behind file (e.g.: MyForm.xaml.cs).
Open the XAML file, and modify the Label element so that the Text attribute is
Text = "Hello, World!"
Modify the body of GetMainPage in your App.cs to the following:
return new MyForm();
Run the app
Hope this helps!
You got it wrong. Forms are created either through code or XAML. No axml or anything persistent is generated at platform level, everything is done in runtime(XAML is sort of compiled at compile time).
So, modify either code or XAML if you wish to change something. Or, if you need something more demanding, than consider either subclassing an existing Renderer or create you own.
my app has a styles.xml file with various visual constants defined.
I'd like my users to be able to switch the entire app to an alternative visual theme. I'd like to provide an alternative styles2.xml file and switch at runtime (via the Settings).
Is this possible, and how? I suspect the style names' appearance in the generated R class does not bode well.
If it's not possible, what's my next best option?
Not sure if anyone is still interested but I have found a possible solution. A bit hackish but gets the desired result.
Basically I set up my 2 style files in separate country code directories:
res/values-mcc199/style.xml
res/values-mcc198/style.xml
Then in my activity I use the following to change which is referenced:
Configuration config = new Configuration();
config.mcc = 199;
getBaseContext().getResources().updateConfiguration(config,null);
I've only done some basic testing so far but it appears to work. Obviously if you are already using country code to decide your layouts then this will interfere. I think there may be problems as well if the phone gets an event about a country change.
Actually, after some reading of the doc, it seems that this can be done. Look here.
As it is mentionned :
To create a set of styles, save an XML
file in the res/values/ directory of
your project. The name of the XML file
is arbitrary, but it must use the .xml
extension and be saved in the
res/values/ folder.
Now, if this is logical and I didn't read the doc wrongly, you can create as many styles as you want, reference them in themes.xml with #style/... (if you want to apply it to a whole activity or application) and then, just call
setTheme(R.id.yourtheme)
I think this should work. Have a go at it and tell us?
It's not an exact answer; in my blog post here:
http://blog.blundell-apps.com/switching-android-configurations-using-constants-and-ant/
I switch out a java class at build time using Ant, there is nothing to stop you switching out an XML file, as it compiles after the switch. To amend the tutorial you'd just have to change the path's of the file your templating.
Also mirrored on GitHub: https://github.com/blundell/BuildChoiceTut