Change the title of Paypal PaymentActivity class - android

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.

Related

Intent setAction ACTION_SNOOZE retired?

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

No "Guided Breathing" Activity Type available through Google Fit SDK

I would like to add a "Guided breathing" activity type, supported by the REST Api under id 122:
https://developers.google.com/fit/rest/v1/reference/activity-types
However, it is not available in the FitnessActivites class, despite the fact that most (all?) other are:
https://developers.google.com/android/reference/com/google/android/gms/fitness/FitnessActivities
Is there a way to add this particular activity type through the Google Fit SDK? I know I can just set a different name with a Session.Builder.setName method, but that wouldn't be sufficiently localised.
This will be available in the next SDK release.
Activity types are just String literals, so I believe you could just use "guided_breathing" in the interim.

Change Android app language with out restarting the app using Restring library

I am using Restring library to load localized strings on my app. And I am able to load localized strings from the api and display it on the app, with out any issues. But the pitfall is every time the language is switched, I have to restart the app, then only the language is updated on the app. But I need to achieve it without restarting the app. Any help is appreciated. I already referred some links, which I am providing below,
https://proandroiddev.com/change-language-programmatically-at-runtime-on-android-5e6bc15c758
https://medium.com/#hamidgh/dynamically-change-bundled-strings-a24b97bfd306
Change app language programmatically in Android
Note: Restring uses SharedPreferences as the String Repository, so
when ever getString(id) method is invoked, it'll provide the string
matching the id from its SharedPrefernces repository.
I would recommend applying View-Model in your android app architecture, A View-Model's major role is to survive configuration changes (which includes but are not limited to orientation changes from landscape to portrait and vice-versa, surviving drastic changes in app's performance stats like power-drain and many more) so you will not need to restart yoour app + additionally use live-Data which is Activity/Fragment aware so it will only update your data of the app when it is in foreground.
There are many YouTube videos specifically teaching these things, I would recommend watching "coding in flow" YouTube channel's MVVM architecture.
It will definitely give you an idea how to continue with your app, it is only 10 videos long but for your requirement first 5 are enough.
You can use a new version of Restring (based on the one you are using) from here:
https://github.com/B3nedikt/restring
It includes a method to update your activity without any restart.
Restring.reword(rootView) will look into all child views of "rootView" and update strings
Restring.setLocale(Locale.FRENCH);
// The layout containing the views you want to localize
final View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
Restring.reword(rootView);
It also explains how to make sure each activity will get the desired strings when created:
in all activities, add:
#Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(ViewPumpContextWrapper.wrap(Restring.wrapContext(newBase)));
}
#Override
public Resources getResources() {
return Restring.wrapContext(getBaseContext()).getResources();
}

Tutorial first time you enter into an app?

I'm programming an app using android studio. I want to know in which way I can do a tutorial that users will see only the first time that use the app. Tutorial like image or screenshoots
Can someone help me? Thanks
I encountered this thread while looking for a solution for running a tutorial only at the first time (as rbaleksandar suggested), so in case it will be helpful for someone someday, here's a template of a solution that works for me (using the SharedPreferences API):
#Override
protected void onResume() {
super.onResume();
String tutorialKey = "SOME_KEY";
Boolean firstTime = getPreferences(MODE_PRIVATE).getBoolean(tutorialKey, true);
if (firstTime) {
runTutorial(); // here you do what you want to do - an activity tutorial in my case
getPreferences(MODE_PRIVATE).edit().putBoolean(tutorialKey, false).apply();
}
}
EDIT - BONUS - If you're into app tutorial - I'm messing now with the ShowcaseView library (which is amazing - try it out). Apparently they have some shortcut for that issue using a method called singleShot(long) - its input is a key for the SharedPreferences, and it does the exact same thing - runs only in the first activation. Example of usage (taken from here):
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_shot);
Target viewTarget = new ViewTarget(R.id.button, this);
new ShowcaseView.Builder(this)
.setTarget(viewTarget)
.setContentTitle(R.string.title_single_shot)
.setContentText(R.string.R_string_desc_single_shot)
.singleShot(42)
.build();
}
You could always code your own solution, but, let us not reinvent the wheel.
Check this Android Library:
Tour Guide Repository
It allows you to add pointers in your screen, so the user knows where is he supposed to touch next.
It's pretty easy to use, you only need to point to the element you want the user to touch.
From the doc:
Let's say you have a button like this where you want user to click on:
Button button = (Button)findViewById(R.id.button);
You can add the tutorial pointer on top of it by:
TourGuide mTourGuideHandler = TourGuide.init(this).with(TourGuide.Technique.Click)
.setPointer(new Pointer())
.setToolTip(new ToolTip().setTitle("Welcome!").setDescription("Click on Get Started to begin..."))
.setOverlay(new Overlay())
.playOn(button);
Hope this helps!
Some links to libraries for creating introduction and/or tutorial screens.
Horizontal cards like Google Now:
https://github.com/PaoloRotolo/AppIntro
Tutorial screen:
https://github.com/amlcurran/ShowcaseView
As far as I understand the question is not How do I create a tutorial? (as the people who have already posted an answer have concluded) but instead How to show a tutorial upon first launch only?. So here are my two cents on this topic:
I'm not familiar with how your Android app stores its configuration data but I will assume that it's either in a database (SQLite) or a text file (plaintext, YAML, XML - whatever). Add a configuration entry to wherever the app's settings are being stored - something like tutorial_on : false, tutorial_on : 1 etc. depending on the format the configuration is represented in.
The way configurations work is that whenever an app (or software in general) is launched it has to be loaded in the app itself. So add the following to your app (where and how is up to you and your app design):
Check tutorial_on entry
If tutorial_on is set to true/1 whatever
2.1 Display tutorial
2.2 Change tutorial_on to false/0 whatever
2.3 Store the result in your configuration
Continue using the app
By doing so the first time your app launches the flag responsible for displaying the tutorial will be toggled and afterwards every time you start the app the toggle flag will be read leading to omitting the tutorial.
Personally I would suggest that you an option similar to Don't show tutorial anymore along with a description how to re-enable it (by triggering some action in that app's menu etc.). This has two major benefits:
Improved user experience - users like to have control (especially over trivial matters such as showing or hiding a tutorial). Whenever you take the control away from them, they get pissed off.
Enable your user to re-learn forgotten things - a general rule of thumb is to create apps that should not burden the user with a lot of stuff to remember. That is why things should be self-explanatory. However sometimes you may want to do that nonetheless. By adding the possibility that the user re-launches (by simply resetting the tutorial_on flag and repeating the steps from above) the tutorial allows just that - refreshing a user's memory.

Where can I find the source code of Android class SQLiteOpenHelper?

I want to take a look at the Android SQLiteOpenHelper class implementation, can somebody points me the location?
The link you want is:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/database/sqlite/SQLiteOpenHelper.java
But even better let me share a great tip:
This extension for Google Chrome
https://chrome.google.com/webstore/detail/android-sdk-search/hgcbffeicehlpmgmnhnkjbjoldkfhoin?hl=en-GB adds the ad (as in Android Developer) keyword to your searchbar so you can type ad TextView and it will bring you directly to TextView on this example AND will add a link "View Source" next to the class name inside the site https://developer.android.com/reference so for any class you want to see the source it's just a click away.
You can find all the existing versions here: http://grepcode.com/search?query=SQLiteOpenHelper&n=

Categories

Resources