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?
Related
I have a fragment in a navigation graph with two parameters (ids: List<Int>? and name: String?) - these both have default values set (both set to #null).
I have created a deeplink to this fragment from the pattern mysite.com/{name} but after upgrading to navigation version 2.4.0-alpha08 I get this error when running my app:
Caused by: java.lang.IllegalArgumentException: Deep link mysite.com/{name} can't be used to open destination Destination(com.mysite:id/myFragment) class=com.mysite.MyFragment.
Following required arguments are missing: [ids]
As the exception is thrown when inflating my MainActivity.xml, it seems like the default value for ids is being ignored when validating the deeplink.
This didn't happen in version 2.4.0-alpha06.
Is this a bug in this version of the navigation component (I'll raise a bug if so), or is this just better validation in that component revealing a bug in my code - if so, what's the fix?
Horribly, here's the hack I'm using.
URL parameters are optional if their value has a default set, so my deeplinks in the navigation graph now look like this:
mysite.com/{name}?this_wont_ever_really_happen={ids}
which matches the url mysite.com/{name} because ids has a default value (of #null)
Jetpack Navigation version 2.5.0-alpha04 release note mentions a fix to solve this kind of problem:
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'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;
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.
I included paypal sdk in the app and set the product name and price as shown in the attached image.
Is it possible to change the title of the paypal PaymentActivity class . ?
I used the entire code for paypal from this link
.Please suggest whether we could change the title to any text ,(I want to change the text that is marked in Red Circle)?
Jeff here from the PayPal Mobile SDK team.
The PayPal Android SDK doesn't support modifying any of the SDK activities. We don't plan to allow the ability to modify titles, as this would be an inconsistent user experience. However, we're open to feedback from users, so please feel free to file issues in GitHub if you have feature requests!
Couple observations, apparently:
The activity of off which you have put screenshot is PaymentMethodActivity (according to Hierarchy Viewer)
PayPal SDK uses ABS
According to the sample app provided in PayPal SDK page, onBuyPressed() launches PaymentActivity with startActivityForResult():
Now, according to SDK references, PaymentActivity does not provide any API for setting custom title. The page lists setTitle() as a part of "Methods inherited from class android.app.Activity", but does not give any details on how to extend PaymentActivity so that one could leverage those APIs.
So, currently, there is no way to use a custom title.
I personally would not bother to change the title on that screen as it clearly depicts itself as a PayPal screen (as one would see their homepage on a browser), but if you really want a custom title, you may need to file a new issue on their GitHub page.
Your AndroidManifest.xml file should have an entry for the PaymentActivity that looks like this:
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
All you should have to do is add the label attribute to that to change the title:
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" android:label="#string/some_title" />
For other potentially useful attributes, refer to the activity tag documentation.
Note: I'm assuming here that the PayPal SDK will allow you to override the title. That is, I would expect it to only set a default title if none is given explicitly.
Edit: Unfortunately, the assumption above has proven to be incorrect. Diving a little deeper, it turns out every activity in the PayPal SDK always sets its title in the onCreate() method. That's actually a little surprising, because that means that PayPal isn't leveraging Android's built-in support for localisation and resources. Although I suppose it does allow them to offer developers the SDK as a jar, which doesn't support bundling Android resources.
In any case, since the various activities haven't been declared final, you could simply try to extend them and set the title after the super has done its work:
public class TitlePaymentMethodActivity extends PaymentMethodActivity {
#Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Custom Title")
// or:
setTitle(R.string.custom_title);
}
}
After that, you'll have to change the manifest to point to your TitlePaymentMethodActivity, in stead of directly to the activity in the SDK. Do note that this approach may break at any point, if PayPal decides to finalize the activity classes. With that in mind, I suggest you follow #shoe rat's recommendation and file a request with PayPal for 'official' support.