In IOS I have 2 apps (App A and App B) that will be performing different objective but at 1 point, App A will call App B using uri scheme to perform a function where App A does not have.
I wanted to implement this function to Android and currently have developed a demo for initiating call to App B. Now I am working on App B that will be receiving the uri scheme from the demo app.
Problem:
After App B return to the demo app using uri scheme I close the demo app.
When I go back to home page and open the multitask to reopen App B(or open App B through the icon), the page it reopen is the function that is used for demo app but what I wanted is the login page of App B.
This is a part of the Manifest for the intent-filter
<activity
android:name="com.apps.MasterActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:clearTaskOnLaunch="true"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data
android:host="x-callback-url"
android:scheme="myapp" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
This is where I call back to the demo app
Intent sendIntent = new Intent(Intent.ACTION_VIEW, responseUri);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(sendIntent);
Try adding this to your activity tag in AndroidManifest.xml
android:clearTaskOnLaunch="true"
Apparently I kinda found a solution that can force the app to show the login page after going back to the demo app. By putting this code in the activity.java file.
#SuppressWarnings("deprecation")
#Override
public void onDestroy()
{
super.onDestroy();
System.runFinalizersOnExit(true);
System.exit(0);
}
I know its a deprecated function that I'm using but will try to solve it when there's something wrong in the future or when I found a better solution for it.
Edit:
Found a better solution that does not need to use the deprecated function which I have forgotten to set it to false.
I have a flag that is set to true when the app is connected through Uri Scheme which i just have to set it to false and it will be fixed. This is the change location that I made
Intent sendIntent = new Intent(Intent.ACTION_VIEW, responseUri);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(sendIntent);
Util.isUriScheme = false;
Related
I have read a lot of question on stackoverflow but none of them answer the question.
I am trying to set up dynamic links so that a link will deep link the user to the app if they already have it installed and the play store if they don't. I expect the link to survive the play store installation process and be sent to the launcher activity with the link. The dynamic link works when the app is already installed. However, when the app is not installed, it sends the user to the play store but the dynamic link does not survive the installation process. I have read that the "Open" button is supposed to change to "Continue" when the user is sent to the play store with a dynamic link, but when I do it, it still says "Open". Here is my activity in AndroidManifest.xml for the activity
<activity
android:name="com.xxx.xxx.xxx.xxx"
android:label="#string/app_name"
android:theme="#style/AppTheme.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="yyy.page.link"
android:scheme="http" />
<data
android:host="yyy.page.link"
android:scheme="https" />
</intent-filter>
</activity>
The Activity is as follows:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ia_login);
checkIfReferral();
}
private void checkIfReferral(){
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
#Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
// Get deep link from result (may be null if no link is found)
Uri deepLink = null;
Log.w(TAG, "FBDL we have a dynamic link");
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
}else{
Log.w(TAG, "FBDL pending dynamic Link Data is null , returning " );
return;
}
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
Boolean ret1 = (user==null);
Boolean ret2 = (deepLink !=null);
Boolean ret3 = (deepLink.getBooleanQueryParameter("invitedby", false));
referrerUid = deepLink.getQueryParameter("invitedby");
if (deepLink != null && deepLink.getBooleanQueryParameter("invitedby", false)) {
referrerUid = deepLink.getQueryParameter("invitedby");
createAnonymousAccountWithReferrerInfo(referrerUid);
}
}
}).addOnFailureListener(this, new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.w(TAG, "FBDL we couldnt receive dynamic link");
}
});
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if(user !=null) {
Log.w(TAG, "FBDL if use != null");
userRecord = FirebaseDatabase.getInstance().getReference()
.child("users")
.child(user.getUid());
}
}
I have added the dynamic link. It is the same as declared in the manifest file. I have added SHA 256 generated from the release key that i signed the app with. The app is on Google Play Store production release.
Please let me know what the mistake is.
Why don't I see "continue" on the Google Play store when dynamic link took me there?
You have to add an auto-verified intent filter to the Activity that will handle the Dynamic Link, setting the host to your project's Dynamic Links domain as found in the Firebase console. In the AndroidManifest.xml:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="yyy.page.link" android:scheme="http"/>
<data android:host="yyy.page.link" android:scheme="https"/>
</intent-filter>
Note that the android:host must be set to your Dynamic Links domain, and not the domain of your deep link.
More informations here
I see that App Links is enabled in your implementation of Firebase Dynamic Links. App Links require the Dynamic Link domain to be added in the Manifest intent-filter, but Dynamic Links still needs to have intent-filter for the deep links that the app will receive. By adding deep links in the intent-filter, not only that it makes FDL to work with the app, but it also ensures that the app will still work if a regular link is used.
If you're still having issues after this, you can file a ticket here https://firebase.google.com/support. You may need to share the Dynamic Link and the Firebase SDK version you're using.
i think you need to enable link handling verification for your app. here is more details
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="yyy.page.link" android:scheme="https"/>
</intent-filter>
A Dynamic Link is a deep link into your app that works whether or not your app is installed. On desktop it will go to the deep link URL
Please check your mobile browser mode. Is desktop mode enabled? if yes, then on link click, it will redirect on URL only not to google play store.
I am developing an application for searching for places. In the application there is a button where user can share a specific place with other user. I was thinking about sharing a link that when other user, "the invited one", clicks on it, my application opens on the shared place page. Just like Clash Royale game, if you know it. The idea is that. How can I do so? Does anyone have idea how to implement this?
Thanks in advance.
To achieve this you need to Create Deep Links to App Content
Code would be something like this:
1) Add intent filter in your activity
<activity android:name="...">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:scheme="schemeName" />
</intent-filter>
</activity>
2) Get data in you activity
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
3) Create sharable URL
eg - http://example.com?data=<your data to share>
4) Now you need to write some script for your page (http://example.com)
that will receive your header data and redirect to open app.
for this get some idea from here
* This is not a complete code but hope will help you.
I was wondering if it is possible to make an android app and when the user hits the launch icon, the browser opens with a specific URL. I know that you can make shortcuts on your phone home screen with the URL you want but I was wondering if it is possible as an android app. So the app should don almost nothing just when i tap on it the browser should open..
is this possible? and is yes how should I think it?
Do this in the main activity's onCreate:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://stackoverflow.com"));
startActivity(intent);
finish();
}
in the manifest add noDisplay theme:
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme = "#android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I am new in android development, I want to build a music player but the problem in front of me is how do i make my app open from gallery.
For example,
if we want to open any music file then we select it, the the android mobile ask which player do we want to use.
so how can I add my app in that option.
please help.
If you want your app to be in the list for opening an audio file, you need to tell the system your app can open those files. You can do that by adding something like the following to your activity tag in your AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content"/>
<data android:scheme="file"/>
<data android:mimeType="audio/*"/>
<data android:mimeType="application/ogg"/>
<data android:mimeType="application/x-ogg"/>
<data android:mimeType="application/itunes"/>
</intent-filter>
Intent filters are part of the core principles in Android development. You should try to get some knowledge on these basic topics before getting started.
It helps you
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(YOUR_SONG_URI);
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent);
Actually you can open activity not app at self just simply add action intent filter in mainfest like this
<activity class=".foo" android:label="#string/title_notes_list">
<intent-filter>
<action android:name="com.me.love" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
other app code :
Intent intent = new Intent("com.me.love");
startActivity(intent);
however if you want to tell android system that your activity can handle some actions like share or send data you just have to add "send" action to your activity in mainfest like so :
<activity class=".boo" android:label="#string/title_notes_list">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
so now when ever user click share button android system will check all activitys that have action string "android.intent.action.SEND" then give the user list of activitys that have send action and if you did added same action as boo activity dose to your activity then it will be one of chooses in the list.
I want to add a feature to my app that when I touch the number in a message, the user can decide to send the number to my app or Android Dialer.
For example my friend send me a code and i want to use this code for special ussd code that my app run it.
I think I have to use implicit intent but I don't know how?
Thanks
I have quoted the below links
-intent filter
-Intents implicit\explicit
Implicit intents specify the action which should be performed and
optionally data which provides data for the action.
For example the following tells the Android system to view a webpage.
All installed web browsers should be registered to the corresponding
intent data via an intent filter.
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.vogella.com")); startActivity(i);
If an Explicit intent is send to the Android system, it searches for all
components which are registered for the specific action and the
fitting data type.
If only one component is found, Android starts this component
directly. If several components are identifier by the Android system,
the user will get an selection dialog and can decide which component
should be used for the intent.
How to use
You can register your own components via Intent filters. If a
component does not define one, it can only be called by explicit
intent.
Register an activity as Browser
<activity android:name=".BrowserActivitiy"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
</intent-filter>
</activity>
UPDATES
A code sample for mimeType
<activity android:name="ShareActivity">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="image/*"/>
</intent-filter>
I assume you are talking about a number in a SMS that you received. On clicking that number you want the user to get an option to either dial or use your app.
If yes then you need to include intent filter in your manifest file for launcher activity.