React Native app takes time for first launch - android

after using react-native-bootsplash library, my app takes time to launch for the first time, and also after submitting the releasing version on the play store, I'm getting Pre-Launch report as: Your app took 22,761ms to launch for the first time.
I also noticed the same on the iOS too, here is my configuration:
My MainActivity.java file:
package com.qadaapp;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import android.os.Bundle;
import com.zoontek.rnbootsplash.RNBootSplash;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
#Override
protected String getMainComponentName() {
return "Qadaapp";
}
/**
* Returns the instance of the {#link ReactActivityDelegate}. There the RootView is created and
* you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
* (Paper).
*/
#Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new MainActivityDelegate(this, getMainComponentName());
}
public static class MainActivityDelegate extends ReactActivityDelegate {
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
super(activity, mainComponentName);
}
#Override
protected ReactRootView createRootView() {
ReactRootView reactRootView = new ReactRootView(getContext());
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
return reactRootView;
}
#Override
protected boolean isConcurrentRootEnabled() {
// If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
}
}
#Override
protected void onCreate(Bundle savedInstanceState) {
RNBootSplash.init(this);
super.onCreate(null);
}
}
My AndroidMainfest.file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.qadaapp">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<application android:name=".MainApplication" android:label="#string/app_name" android:icon="#mipmap/ic_launcher" android:roundIcon="#mipmap/ic_launcher_round" android:allowBackup="false" android:usesCleartextTraffic="true" android:theme="#style/BootTheme">
<activity android:name=".MainActivity" android:label="#string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:exported="true">
<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="qadaapp"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="#string/app_name"/>
<activity android:name="com.facebook.CustomTabActivity" android:exported="true">
<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="#string/fb_login_protocol_scheme"/>
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="#string/facebook_client_token"/>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
My styles.xml file:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">#drawable/rn_edit_text_material</item>
</style>
<!-- BootTheme should inherit from Theme.SplashScreen -->
<style name="BootTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#color/bootsplash_background</item>
<item name="windowSplashScreenAnimatedIcon">#mipmap/bootsplash_logo</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
</resources>
Also I added this in my build.gradle file:
implementation "androidx.core:core-splashscreen:1.0.0"
My App.js:
const unsubscribe = auth().onUserChanged(async usr => {
if (!usr) {
await _getSlideShows();
setUser(null);
return RNBootSplash.hide({fade: true});
}
if (usr?.uid) {
let dbResult = await DB.collection('users').doc(usr?.uid).get();
setUser(usr);
if (dbResult?.exists) {
let dbUser = dbResult.data();
setUser(dbUser);
}
return RNBootSplash.hide({fade: true});
}
});
return () => unsubscribe();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
When I was not using react-native-bootsplash, the app was working fast, however when I implemeneted the react-native-boot-splash library, my app's cold start time increased on both the platforms.

Related

Why am I getting a MissingPluginException when using platform-specific code (Kotlin) in my Flutter app?

I've been trying to use Android code in a Flutter project to do audio-related tasks, and I've been following Flutter's guide to do so. However, when I try to call the method on the method channel, I've been getting a MissingPluginException that says that the method (getAudioSessionID) isn't implemented. I found a post on a similar issue, but it doesn't seem like it was solved. I put some print statements in MainActivity, but they aren't being called.
This is what the MainActivity class looks like in MainActivity.kt:
class MainActivity: FlutterActivity() {
private val CHANNEL = "XXX.XXX/eqAndroid"
override fun configureFlutterEngine(#NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
call, result ->
print("This is being called")
if (call.method == "getAudioSessionID") {
val audioSessionID = getAudioSessionID()
print(audioSessionID)
} else {
result.notImplemented()
print("else block in if/else statement")
}
}
}
private fun getAudioSessionID(): String {
return AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION
}
}
I defined a global variable for the method channel in a constants.dart file:
const eqAndroidPlatform = MethodChannel('XXX.XXX/eqAndroid');
, and this is the function that is supposed to invoke the getAudioSessionID method:
Future<void> getAudioSessionID() async {
String audioSessionID;
try {
final String result = await eqAndroidPlatform.invokeMethod('getAudioSessionID');
audioSessionID = 'Currently playing audio session ID is $result .';
} on PlatformException catch (e) {
audioSessionID = "Failed to get audio session ID: '${e.message}'.";
}
setState(() {
this.audioSessionID = audioSessionID;
});
}
This is the code in AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="XXX.XXX.XXX">
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher"
android:label="XXX">
<activity
android:name="com.ryanheise.audioservice.AudioServiceActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:windowSoftInputMode="adjustResize"
tools:ignore="Instantiatable">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.ryanheise.audioservice.AudioService"
android:exported="true" tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver"
android:exported="true" tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<receiver android:name=".receivers.AudioSessionReceiver">
<intent-filter>
<action android:name="android.media.action.OPEN_AUDIO_EFFECT_CONTROL_SESSION"/>
</intent-filter>
</receiver>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

Splash-screen not work in react-native app on android

I have the react-native app and I need to implement a splash screen on android. My step was: put png images to app/src/main/res/mibmap, create background_splash.xml in app/src/main/res/drawable/, add SplashTheme to app/src/main/res/values/styles.xml, change AndroidManifest.xml, change MainActivity.java, create SplashActivity.java class in src/main/java/. But my splash screen is not appearing in the app. Can you explain to me please what I'm doing wrong?
background_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/black" />
<item>
<bitmap
android:src="mipmap/splash_screen"
android:gravity="center" />
</item>
</layer-list>
styles.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<color name="primary_dark">#27409d</color>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<!--<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">#android:color/transparent</item>-->
<!-- fix https://trello.com/c/OuBMJCMI-->
<!-- https://github.com/facebook/react-native/issues/17530-->
<item name="android:editTextBackground">#android:color/transparent</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/background_splash</item>
</style>
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#000000</color>
</resources>
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="broker.mapp"
android:fitsSystemWindows="false">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-sdk />
<application
android:name="broker.mapp.MainApplication"
android:allowBackup="false"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme"
android:networkSecurityConfig="#xml/network_security_config"
android:largeHeap="true"
>
<activity
android:name="broker.mapp.SplashActivity"
android:theme="#style/SplashTheme"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="broker.mapp.MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:launchMode="singleTask"
android:exported="true">
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="broker" android:host="*"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="Без категории"/>
android:value=" "/>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
</application>
</manifest>
MainActivity.java
package broker.mapp;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import io.fabric.sdk.android.Fabric;
import com.crashlytics.android.core.CrashlyticsCore;
import com.crashlytics.android.Crashlytics;
import android.content.Intent;
import android.content.res.Configuration;
import org.devio.rn.splashscreen.SplashScreen;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
#Override
protected String getMainComponentName() {
return "BrokerMapp";
}
#Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this, true);
super.onCreate(savedInstanceState);
CrashlyticsCore core = new
CrashlyticsCore.Builder().disabled(BuildConfig.USE_FABRIC !=
"TRUE").build();
Fabric.with(this, new
Crashlytics.Builder().core(core).build());
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Intent intent = new Intent("onConfigurationChanged");
intent.putExtra("newConfig", newConfig);
this.sendBroadcast(intent);
}
}
SplashActivity.java
package com.app;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, rshb.broker.mapp.MainActivity.class);
startActivity(intent);
finish();
}
}
Try Below code in onCreate method
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent intent = new Intent(SplashActivity.this,MainActivity.class);
startActivity(intent);
finish();
}
}, 3000);

Incorrect Activity when running App Android Studio

I have starting building an app in Android studio. I have established the MainPage as the launcher activity in the manifest.xml.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.NoActionBar">
<activity android:name=".MainPage">
android:screenOrientation="portrait"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".courseSelect" />
<activity android:name=".profile1" />
<activity android:name=".stats1" />
<activity android:name=".ReviewRounds" />
<activity android:name=".ReferFriends" />
<activity android:name=".RangeMode" />
</application>
I have double checked that the run configuration is set to 'Default' and yet the app is running a different activity, entitled courseSelect. It is also not running some code correctly on the NumberPicker. Even though I've set the picker to have a min, max, and default, the picker only shows 0 and will not scroll. The two issues seem to be related somehow, in terms of what activity is being run.
this is the courseSelectCode:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.NumberPicker;
import co.ceryle.segmentedbutton.SegmentedButtonGroup;
public class courseSelect extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_course_select);
//Hole Picker
NumberPicker holePicker = (NumberPicker)findViewById(R.id.holePicker);
holePicker.setMaxValue(18);
holePicker.setMinValue(1);
holePicker.setWrapSelectorWheel(false);
holePicker.setValue(1);
SegmentedButtonGroup sbg = (SegmentedButtonGroup) findViewById(R.id.segmentedButtonGroup);
sbg.setOnClickedButtonPosition(new SegmentedButtonGroup.OnClickedButtonPosition() {
#Override
public void onClickedButtonPosition(int position) {
// if(position == 0)
}
});
}
}
I tried to set the run configuration specifically to the MainPage activity and it still opens in the courseSelect Page.
EDIT: on request, here is my MainPage.java code:
public class MainPage extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_course_select);
Window g = getWindow();
g.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.TYPE_STATUS_BAR);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
...
}
edit the Mainfest.xml, in order to enforce portrait layout there already:
<activity android:name=".MainPage"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...which makes this code merely useless (styles.xml can also be used for window styles):
Window g = getWindow();
g.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.TYPE_STATUS_BAR);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
also update setContentView( R.layout.activity_course_select ); to the proper resource.
because it starts the MainPage Activity, but then inflates the wrong XML file.
one "suggested edit" before was to swap the order of setContentView() and the paragraph below ...which I've rejected, because setting it in Manifest.xml appeared more organized (less code).
First of all There is a mistake in your manifest file
you wrote screenOrientation attribute outside the opening tag
<activity android:name=".MainPage">
android:screenOrientation="portrait"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
it should be
<activity
android:name=".MainPage"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and you used wrong xml to setContenView
Try this and error was in 9th line because your code line is outside of the tag:
<activity android:name=".MainPage">
android:screenOrientation="portrait" // error
Do this :
<activity android:name=".MainPage"
android:screenOrientation="portrait"> // After doing this no error
and do also this thing :
public class MainPage extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_course_select); // error
do this :
public class MainPage extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.MAIN_PAGE_ACTIVITY_NAME); // no error
Your launcher activity is MainPage but you are calling the layout of courseselect activity inside MainPage activity's onCreate method on this line
setContentView(R.layout.activity_course_select);
Change it to your MainPage layout
setContentView(R.layout.yourMainPageLayout);

Where to call the Android Intent handler code in Gluon

Trying to handle the intents that are specified in AndroidManifest.xml. Not sure where to call the Service method that is created. Unlike in native android code where the intents are handled in the activity.
Referring to http://gluonhq.com/handling-android-native-activities-like-a-pro/
tried calling the service in the init method of the main class of the application (But seems like the intent handler methods are not called)
For the Gluon app to receive data from other apps in android
AndroidManifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nativeeg" android:versionCode="1" android:versionName="1.0">
<supports-screens android:xlargeScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="21"/>
<application android:label="NativeEg" android:name="android.support.multidex.MultiDexApplication" android:icon="#mipmap/ic_launcher">
<activity android:name="javafxports.android.FXActivity" android:label="NativeEg" android:configChanges="orientation|screenSize">
<meta-data android:name="main.class" android:value="com.nativeeg.NativeEg"/>
<meta-data android:name="debug.port" android:value="0"/>
<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.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<activity android:name="com.gluonhq.impl.charm.down.plugins.android.PermissionRequestActivity" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
The Native Service to handle the intent
import nativeutility.ReceiveFromApps;
import javafxports.android.FXActivity;
import android.content.Intent;
/**
*
* #author Vaishnavi
*/
public class AndroidReceiveFromApps implements ReceiveFromApps{
#Override
public void receiveData() {
Intent intent = FXActivity.getInstance().getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
System.out.println("in handle intent!");
if ("text/plain".equals(type)) {
// Handle text being sent
System.out.println("text data");
} else if (type.startsWith("image/")) {
// Handle single image being sent
System.out.println("image data");
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
System.out.println("in handle intent!");
if (type.startsWith("image/")) {
// Handle multiple images being sent
System.out.println("multiple image data");
}
} else {
// Handle other intents, such as being started from the home screen
}
}
}
Gluon Main class:
public class NativeEg extends MobileApplication {
#Override
public void init() {
AppViewManager.registerViewsAndDrawer(this);
System.out.println("in main");
Services.get(ReceiveFromApps.class).ifPresent(service -> service.receiveData());
}
...
package nativeutility;
import com.gluonhq.charm.down.DefaultServiceFactory;
public class ReceiveFromAppsFactory extends DefaultServiceFactory<ReceiveFromApps> {
public ReceiveFromAppsFactory() {
super(ReceiveFromApps.class);
}}
Interface
package nativeutility;
public interface ReceiveFromApps {
public void receiveData();
}

Android debug app is not opening using branch.io

I am working on deeplinking part in android, I have found branch.io provides deeplinking support. I followed everything as per documentation but still it is opening custom link instead of app.
code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="branch.next.com.newbranchapp">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:name="io.branch.referral.BranchApp""
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Branch URI scheme -->
<intent-filter>
<data android:scheme="branch" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<!-- Branch init -->
<!-- Branch init -->
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_abFuXvh4EU7Yocf2FB4jJpccAEcz3sZT" />
<meta-data android:name="io.branch.sdk.BranchKey.test" android:value="key_test_cbvEXCcXuJ27ojf1yu9sTkaitsoF0v9X" />
<!-- Branch testing (TestMode "true" to simulate fresh installs on dev environment) -->
<meta-data android:name="io.branch.sdk.TestMode" android:value="true" />
<!-- Branch install referrer tracking -->
<receiver android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</application>
</manifest>
public class MainActivity extends AppCompatActivity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public void onStart() {
super.onStart();
Branch branch = Branch.getInstance();
branch.initSession(new Branch.BranchUniversalReferralInitListener() {
#Override
public void onInitFinished(BranchUniversalObject branchUniversalObject, LinkProperties linkProperties, BranchError error) {
if (error == null) {
Log.i("MyApp","not working");
} else {
Log.i("MyApp", error.getMessage());
}
}
}, this.getIntent().getData(), this);
}
#Override
public void onNewIntent(Intent intent) {
this.setIntent(intent);
}
}
// application
public class CustomApplication extends Application
{
#Override
public void onCreate()
{
super.onCreate();
Branch.getAutoInstance(this);
}
}
Amruta from Branch.io here:
Two things:
The name of your Application class is "CustomApplication" but in your Manifest I see the name for your Application class set to "android:name="io.branch.referral.BranchApp"". I am not sure but I believe this should give you errors in your App. This should be set to ".CustomApplication"
I just took a quick look at your Branch dashboard. Since you are testing with a link from the test version of your app (Links from the test version have the link domain of the type ".test-app.link") you should populate the Android URL for the test version in your Link Settings. You can switch between the 'Live' and 'Test' using the flipper on the top-left corner of the dashboard.

Categories

Resources