We are not access share url from firebase using "https://firebase.google.com/docs/dynamic-links/android/receive"
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;
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
Log.e("deepLink",""+deepLink.toString());
}
// Handle the deep link. For example, open the linked
// content, or apply promotional credit to the user's
// account.
// ...
// ...
}
})
.addOnFailureListener(this, new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.w(TAG, "getDynamicLink:onFailure", e);
}
});
this method of firebase is allways return null in "onSuccess".
first you need to make sure you URI is formulated like
https://your_subdomain.page.link/?link=your_deep_link&apn=package_name[&amv=minimum_version][&afl=fallback_link]
method getDynamicLink returns null if a dynamic link is not previously captured or is in the Uri, the above link format is not necessarily to be like that but it should match to the intent filters you have previously defined.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".EntryChoiceActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".java.MainActivity"
android:exported="true">
<!-- [START link_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="link"
android:scheme="your_subdomain.page.link"/>
</intent-filter>
</activity>
</application>
</manifest>
also you should add query parameters to the link field in the firebase console, https://your_subdomain.page.link/?link=your_deep_link&apn=package_name[&amv=minimum_version][&afl=fallback_link] and deep link remain short https://your_subdomain.page.link/example now to reproduce an adb test for a intent filters like:
<activity
android:name=".ui.activities.MyActivity"
android:label="#string/title_activity"
android:screenOrientation="portrait">
<!-- ATTENTION: This intent was auto-generated. Follow instructions at
https://g.co/AppIndexing/AndroidStudio to publish your Android app deep links. -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- ATTENTION: This data URL was auto-generated. We recommend that you use the HTTP scheme.
TODO: Change the host or pathPrefix as necessary. -->
<data
android:host="link"
android:scheme="your_subdomain.page.link" />
</intent-filter>
</activity>
use:
adb shell am start -W -a android.intent.action.VIEW -d "your_subdomain.page.link://link?key=category_parent_id\&value=92\&title=test" com.app_name.android
Hope this help thanks.
Related
I am working on an app In this, I have to send the current status of the android devices in 30-30 seconds through my app which I have done. But the problem I am facing is the app is not starting after boot complete this problem is related to some of android devices.
MY Code is:
public class BootCompletedReceiver extends BroadcastReceiver {
private static final String TAG = "BootCompletedReceiver";
#Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG,"action : "+intent.getAction());
if (Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_BOOT_COMPLETED)){
Log.d(TAG,"receive boot completes : "+intent.getAction());
#SuppressLint("StaticFieldLeak")
AsyncTask task = new AsyncTask() {
#Override
protected Object doInBackground(Object[] objects) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
#RequiresApi(api = Build.VERSION_CODES.O)
#Override
protected void onPostExecute(Object o) {
super.onPostExecute(o);
context.startForegroundService(new Intent(context, StatUpdateService.class));
}
};
task.execute();
}
}
}
Manifests file:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<......./>
<receiver
android:name=".receiver.BootCompletedReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
List item
On Some of the android devices, This Code is working and My app is starting after boot complete, but on the Some of the android devices, it's not working.
Android does not auto-start any application until you manually launch it at least once. After that, the applications will automatically start on each Android boot.
Add android.permission.RECEIVE_BOOT_COMPLETED permission in your manifest.
When Android finishes booting and is ready to start the home activity, the home event is sent and qualifying applications identify themselves as bootable candidates. The system sends out the android.intent.category.HOME and android.intent.category.DEFAULT intents when it's done initializing.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.test.app">
<!-- add this -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:theme="#style/app_theme_red">
<!-- main -->
<activity
android:name=".ui.activity.MainActivity"
android:exported="true">
<!-- main filter -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- add this -->
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- boot receiver -->
<receiver android:name=".BootReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
I have two applications, the first one send an implicit intent to view a link and the second one named "MyBrowser" receives it. But when I install both apps on my phone (API level 23), the app chooser only display the Internet (default application for web viewing). If I use the AVD (API level 25), app chooser includes also "MyBrowser". Here is my first application's function:
private void startImplicitActivation() {
Log.i(TAG, "Entered startImplicitActivation()");
// Create a base intent for viewing a URL
Intent baseIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL));
// Create a chooser intent, for choosing which Activity
// will carry out the baseIntent
Intent chooserIntent = Intent.createChooser(baseIntent, CHOOSER_TEXT);
// Verify the intent will resolve to at least one activity
if (baseIntent.resolveActivity(getPackageManager()) != null) {
Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction());
// Start the chooser Activity, using the chooser intent
startActivity(chooserIntent);
}
And "MyBrowser" Manifest.xml:
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MyBrowserActivity"
android:label="#string/app_name" >
<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:scheme="http" />
</intent-filter>
</activity>
</application>
I am newbie in android and can't understand why. Please explain to me. Thank you.
I have an android project for first time installation.
It is related with my firm agreement pages. It comes after google agreement pages.
I tried some technics for doing it. For example,I set it as a system application. However, it is cleaned when backup and reset operation.
Does anybody know how to run it?
on AndroidManifest.xml
<application
android:theme="#android:style/Theme.NoTitleBar"
android:allowBackup="true"
android:icon="#drawable/launcher"
android:label="#string/appname" >
<activity
android:name="xxxagreement.MainActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter android:priority="3">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
on MainActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
protected void onResume() {
Intent i = new Intent();
i.setAction(AGREEGATE_STARTED);
sendBroadcast(i);
TextView t = (TextView)findViewById(R.id.textView1);
t.setSelected(true);
...
super.onResume();
}
Event Log prints:
Session 'app': Error Launching activity
Your application doesn't have any launcher activity. Replace these lines
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
with
<category android:name="android.intent.category.LAUNCHER" />
When I try access dropbox API with DBRoulette, example application from DropBox API, using Android,
I get the following two messages in the simulator:
Link to DropBox(I click it) then
-Unfortunately browser has stopped.
I've got an APP_KEY, SECRET_KEY from dropbox, my manifest file is:
<uses-sdk android:minSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity
android:name=".DBRoulette"
android:label="#string/app_name"
android:configChanges="orientation|keyboard">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.dropbox.client2.android.AuthActivity"
android:launchMode="singleTask"
android:configChanges="orientation|keyboard">
<intent-filter>
<!-- Change this to be db- followed by your app key -->
<data android:scheme="db-XXXXXXX" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
My main file is DBRoulette, identical to the example app:
com.dropbox.android.sample;
public class DBRoulette extends Activity {
private static final String TAG = "DBRoulette";
///////////////////////////////////////////////////////////////////////////
// Your app-specific settings. //
///////////////////////////////////////////////////////////////////////////
// Replace this with your app key and secret assigned by Dropbox.
// Note that this is a really insecure way to do this, and you shouldn't
// ship code which contains your key & secret in such an obvious way.
// Obfuscation is good.
final static private String APP_KEY = "xxxxxx";
final static private String APP_SECRET = "xxxx";
....
I am using all jars suggested:dropbox-api, http-mime, json-simple, and android 4.4 as the version.
Why can't I access dropbox? is it because the simulator?
It didn't work because it ran on the simulator not on the phone.
Used it on the phone, no problems.
I'm using GCM in my android application and when I try to register the device with GCM (with the command gcm.register(SENDER_ID)) I get the SEVICE_NOT_AVAILABLE error, I tried what someone suggested here (the accepted solution) and I did get the registration id.
Why is it like that?
Android manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appspot.smartgan"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.appspot.smartgan.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.appspot.smartgan.permission.C2D_MESSAGE" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light" >
<activity
android:name="com.appspot.smartgan.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.appspot.smartgan" />
</intent-filter>
</receiver>
<service
android:name=".GcmIntentService"
android:enabled="true" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.appspot.smartgan.LoginActivity"
android:label="#string/title_activity_login"
android:windowSoftInputMode="adjustResize|stateVisible" >
</activity>
<activity
android:name="com.appspot.smartgan.ChildActivity"
android:label="#string/title_activity_child" >
</activity>
</application>
</manifest>
register method:
private void registerInBackground() {
new AsyncTask<Void, Void, String>() {
#Override
protected String doInBackground(Void... params) {
String message = "";
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(context);
}
regid = gcm.register(SENDER_ID);
message = "Device registered, registration ID=" + regid;
Log.d("SMARTGAN_PLAY", "register completed");
// send registration id to the server
sendRegistrationIdToServer();
// Persist the regID - no need to register again.
storeRegistrationId(context, regid);
} catch (IOException e) {
message = "Error:" + e.getMessage();
}
return message;
}
}.execute(null, null, null);
}
I think issue is regarding allowed IP addresses mentioned in your Google API project.
Please check details of the project and remove IP address if present under restrict use to IP address. I faced similar problem.
If you are receiving a Register ID it means you have registered the device successfully to the GCM.
Edit:
Here is a good tutorial for GCM: http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
<receiver
android:name="rockit.app.beardallstreetprimary.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="rockit.app.beardallstreetprimary" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gcm.GCMIntentService" android:enabled="true" />
My GCM is set up based on the Tutorial i linked above so if you read through that aswell it should work for you it looks like your not far off. I will say the Manifest is very picky and you need to ensure that you link your Packages fully.
Also you dont need the Register Intent