Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all 28463 articles
Browse latest View live

how to do chrome cast in JwPlayer for android

$
0
0

I'm trying to cast the videos playing on Jwplayer in near by devices like Tv, Laptop etc.

i followed this tutorial https://developer.jwplayer.com/jwplayer/docs/android-enable-casting-to-chromecast-devices

then on below code

CastOptions castOptions = new CastOptions.Builder()//                .setReceiverApplicationId(context.getString(R.string.app_id))                .setLaunchOptions(launchOptions)                .build();

I didn't get setReceiverApplicationId as i don't have such a id.

So, i went here How do you find your Google Cast App ID (app_id) in the 2017 Google Play Developer Console? and decided not to pay before testing.

Then on Jw docs it is mentioned setReceiverApplicationId() allows you to filter discovery results and to launch the receiver app when a cast session starts

Since i don't need filters i commented that line.

Now i got a cast icon on xml. but when I tap it nothing is happening.

Please someone tell me

  • Is app_id is necessary how to get it ?

  • How to test the chrome casting ?


Can't connect to meteor backend from react native app at android device

$
0
0

I have a meteor webapp and I need to connect to its backend from react native app. I set up sdk, connected my android device and run react-native start and react-native run-android, app gets loaded and client side works, except connection to meteor. I'm using this package https://github.com/inProgress-team/react-native-meteor and trying to connect to my locally running meteor backend with Meteor.connect, using ws://192.168.xxx.xx.x (my local ip address) but it doesn't connect. I've checked iptables and they seem to be clean. What could prevent that connection? What else could I try or check? I'm using Ubuntu 16.04.

What pathPrefix in Android to make entire domain a deep linking?

$
0
0

I want to set up deep linking so that any url of myapp.io is opened by the Android app if installed.

Is this a valid pathPrefix? Or should it be "/*"?

"android": {"intentFilters": [        {"action": "VIEW","data": [            {"scheme": "https","host": "*.myapp.io","pathPrefix": "*"            }          ],"category": ["BROWSABLE","DEFAULT"          ]        }      ]    },The code above is from my app.json as I'm using Expo, but I think it's clear what React Native values they map to. 

what is the alternative for not to hard-code licence key of jwplayer in metadata of android manifest

$
0
0

I'm working on JwPlayer and found that the License key should be given in metadata

<meta-data            android:name="JW_LICENSE_KEY"            android:value="seFyAWPdupaTE/IHIzRQLiJZmw8w0hyN9IZo23oerxapzQQZ3kVuoRgaqqcvwWBG" />

But I want to send it from server for my multi behavior app. Which will look for videos in different account, based on users.

So i tried to write meta data dynamically like below but it wasn't working.

try {            ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);            applicationInfo.metaData.putString("JW_LICENSE_KEY","seFyAWPdupaTE/IHIzRQLiJZmw8w0hyN9IZo23oerxapzQQZ3kVuoRgaqqcvwWBG");        } catch (PackageManager.NameNotFoundException e) {            e.printStackTrace();        }

Is there any way to not hard-code license key in android manifest for JwPlayer ?

Is there a way to record audio with React native and store it as a wave file?

$
0
0

when the user clicks the button, The app should start listening the audio and stop the recording when the user is silent(say for 20 seconds after silence) , now store that audio file in a wave format(eg: test.wav) in react native ?

React Native build failed while executing task > Path is not a readable directory

$
0
0

I used Windows Subsystem for Linux, maybe this is the problem? I will be glad of any help, I will provide the information you need.

> Task :app:processDebugResources FAILED320 actionable tasks: 1 executed, 319 up-to-dateFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:processDebugResources'.> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> Path 'C:\Users\Username\Desktop\react-native-app\node_modules\unimodules-sensors-interface\android\build\intermediates\compiled_local_resources\debug\out' is not a readable directory.

Sendbird push notification when app is in background

$
0
0

Here is my query. I have implemented sendbird sdk in one of my react-native app for chat implementation. I am trying to implement push notifications. I have used react-native-firebase for firebase push notifications as described in sendbird's documentation. Now the issue is my android app is getting push notification when the app is in foreground. OnMessageReceived() listener is triggered for this. But when my app is in background I am not receiving any push notification from sendbird.. None of the firebase notification listeners are triggered.

Also, when I am trying to send notification from firebase console I am receiving foreground as well as background notification.

Hoping for a response from you guys, as this can help me implement this feature successfully.

React Native not detecting Android emulator

$
0
0

When I do react-native run-android I get this error:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 960 file(s) to forward-jetify. Using 6 workers...info Starting JS server.../bin/sh: 1: adb: not foundinfo Launching emulator...error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.info Installing the app...Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warningsFAILURE: Build failed with an exception.* What went wrong:Task 'installDebug' not found in project ':app'.* Try:Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.orgBUILD FAILED in 4serror Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:Task 'installDebug' not found in project ':app'.* Try:Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.org

I dont get it, before I run my React Native app I open the Android emulator first. I also noticed that my android studio doesn't have 'configure' on welcome page, so I have to start a project if I want to acces the sdk manager and avd manager.


react native notification badge count (android)

$
0
0

I'm not sure it's the right place to ask because I don't have a specific problem with my code (yet)But I don't understand something basic about the notification badge count, regarding push notifications (on Android):

I saw this library for example:

react-native-shortcutbadger

and in order to change the badge count we can use:

ShortcutBadger.applyCount(count);

But this should be done on the receiver side? Or when the notification is being sent?What I don't get is that the receiver can have their app shut down, so how will the badge count take place?

On iOS for example you can assign the badge count while sending the notification payload.

Thanks in advance

3D Animations on View with React Native

$
0
0

I want to implement a flip effect in my React Native app, similar like described here:

https://www.codementor.io/reactjs/tutorial/building-a-flipper-using-react-js-and-less-css

My question is. Can I achieve it somehow with the help of some library like 'Animations'https://facebook.github.io/react-native/docs/animations.html or I have to play with 'plain' CSS styles.

What is the 'good practive' for such animations in React Native?

class CardBack extends Component {  render() {    return (<TouchableOpacity onPress={this.flip}><View style={styles.scrumCardBorder}><View style={styles.cardBack}></View></View></TouchableOpacity>    );  }  flip() {    this.setState({flipped: !this.state.flipped})  }}class CardFront extends Component {  render() {    return (<TouchableOpacity><View style={styles.scrumCardBorder}><View style={styles.cardFront}><Text style={styles.cardValue}>5</Text></View></View></TouchableOpacity>    );  }}

How to change background color of software home/back buttons on Android?

$
0
0

Many Android devices use software home/back buttons at the bottom of the screen. Various apps change the color of those buttons to better match the app color theme.

How can these colors be changed in React Native? (Preferably programmatically, so light and dark screens could use different button colors.)

Image of Android software buttons

React Native Map Callout Issue, Map Popup Button click not working

$
0
0

I want to click of Button inside map popup in react native so below is my code

render() {    console.log(TAG +"in render")    return (<View style={{ flex: 1 }}>        {                            (this.state.coords != null) ?<MapView                                    style={styles.map}                region={this.state.mapRegion}                showsUserLocation={true}                followUserLocation={true}                onRegionChange={this.onRegionChange.bind(this)}                onPress={this.onMapPress.bind(this)}>< MapView.Polyline                    coordinates = {                        this.state.coords                    }                    strokeWidth = {                        4                    }                    /><MapView.Marker                             coordinate={                                {                                    latitude: this.state.lastLat,                                    longitude: this.state.lastLong,                                }                            } ><MapView.Callout tooltip><View style={styles.bubble}> <View ><Button title='Click Me!' onPress={() => alert('Click')} /></View>      </View>                                   </MapView.Callout></MapView.Marker>< MapView.Marker                            coordinate={                                {                                    latitude: this.state.destination.latitude,                                    longitude: this.state.destination.longitude,                                }                            }                        /></MapView> :null        }</View>    );}

My stylesheet as below

const styles = StyleSheet.create({bubble: {    width: 140,    justifyContent: 'center',    alignItems: 'center',    flexDirection: 'row',    padding:5,  },    bubblecontent: {        padding:5,    },     bubbleContentTextStyle:{        fontSize:10,    },    iconContainer:{        height:'50%',        justifyContent: 'center',        alignItems: 'center',                },    iconStyle   :{      height:15,      weidth:15,      backgroundColor: 'blue'    },    map: {        ...StyleSheet.absoluteFillObject,    },  });

When I run above code in Android I am not getting click of Button which is I put inside MapView.Callout.

onPress={() => alert('Click')} 

I am not able to get alert on button click, Any idea how can I get button click? All your suggestions are appreciable.

How solve this issue in react native

$
0
0

$ npx react-native run-androidinfo Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 864 file(s) to forward-jetify. Using 4 workers...info Starting JS server...info Launching emulator...error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.info Installing the app...

FAILURE: Build failed with an exception.

  • What went wrong:Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

  • Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 23s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong:Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

  • Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 23s

at checkExecSyncError (child_process.js:629:11)at execFileSync (child_process.js:647:13)at runOnAllDevices (E:\work\react-native\AwesomeProject1\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)

after install react-native-device-info error android

$
0
0

enter image description here

FAILURE: Build failed with an exception.

  • Where:Build file 'D:\AndroidApps\SenFinApp\node_modules\react-native-device-info\android\build.gradle' line: 29

  • What went wrong:A problem occurred evaluating project ':react-native-device-info'.

    Could not find method implementation() for arguments [com.facebook.react:react -native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies. DefaultDependencyHandler.

  • Try:Run with --stacktrace option to get the stack trace. Run with --info or --debugoption to get more log output.

BUILD FAILED

Total time: 6.084 secs

D:\AndroidApps\SenFinApp\android>

I tried to get deviceId using react-native-device-info in react native.then I got below error.use React-native version"react-native": "0.48.3",

in line 29

implementation 'com.facebook.react:react-native:+'

I follow the instructions of below link:

https://github.com/rebeccahughes/react-native-device-info

please help me

Thanks.

how to get a response from native module to React native

$
0
0

Hey there i am working with a react native project , i need to send a message in background without any user interactions until now everything's good but the problem is how can i get the result i find a lot of solution with native android like broadcasting but i couldn't know how to use anyone of them ? so how can i send back the result of smsmanager to react native ?

here is my android class

package com.nomadeflash;import com.facebook.react.bridge.ReactApplicationContext;import com.facebook.react.bridge.ReactContextBaseJavaModule;import com.facebook.react.bridge.Callback;import com.facebook.react.bridge.ReactMethod;import com.facebook.react.uimanager.IllegalViewOperationException;import android.telephony.SmsManager;public class DirectSmsModule extends ReactContextBaseJavaModule {    public DirectSmsModule(ReactApplicationContext reactContext) {        super(reactContext); //required by React Native    }    @Override    //getName is required to define the name of the module represented in JavaScript    public String getName() {         return "DirectSms";    }    @ReactMethod    public void sendDirectSms(String phoneNumber, String msg, Callback successCallback) {        try {                  SmsManager smsManager = SmsManager.getDefault();            smsManager.sendTextMessage(phoneNumber, null, msg, null, null);              successCallback.invoke("passed","not passed");        } catch (Exception ex) {            System.out.println("couldn't send message.");        }     }}

How to develop an email client app using react native

$
0
0

I want to build an email client app using react-native. I found some posts related to this Developing an email client app on android. Hontvári Levente posted answer here to use PopMailImporter.java. I found a similar solution in react native. It is to use Linker, but it is not a 'client app'. I have two questions: Are there any solutions to build email client apps using react native? What is the best (popular) solution to build email client apps using android studio?

Fetch in react native wont work with ssl on android

$
0
0

When I'm using the fetch function in my react native apps, things work as expected on iOS, but gives an error in android. The error is 'TypeError: Network request failed'. Doing a bit of debugging, I found that the cause of the error seems to be the following: 'java.security.cert.CertPathValidatorException: Trust anchor for certification path not found'.

How come this works in iOS and not on android, and how do I best fix it? Is the fault in react-native, or somewhere deeper?

How to get android app versionName from AirWatch APIS

$
0
0

I want to fetch versionName of all app/product deployed to AirWatch, using Airwatch api'sbut I am not sure if any API available for that or not.

I searched in document but I am not able to find any api name. Can anyone tell me service name to get versions of android application.

Edit1:Below calls not returning any data. am I missing something

https://host/api/mdm/devices/apps?searchby=idTest&id=1520&pageTest=1https:host/api/mdm/devices/1520/apps?page={page}&pagesize=1

This way calling other services and working

"https://host/api/mdm/devices?searchby=Serialnumber&id=jjjQA7AL"

Edit2: When I am using URI

https://host/api/mdm/devices/apps?searchby=Serialnumber&id=R10QA7AL&page=1&pagesize=1

Getting kind of sample data(not related to my products)

{"DeviceApps":[{"ApplicationName":"Amazon Kindle","Version":"8.21.1.0","BuildVersion":"","Status":2,"Size":"122252286","ApplicationIdentifier":"com.amazon.kindle","Type":"System","IsManaged":false}],"Page":1,"PageSize":1,"Total":61}

Stuck on splash screen on first launch but if we don't kill app and launch app again the app works fine. (react-native) Android

$
0
0

I have upgraded code to react-native 0.59.9 from 0.53.3. I think I may have missed some essential steps and getting launch issues. Please check and help me to make app work fine.

React Native Navigation version: 4.0.6

React Native version: 0.59.9

Platform(s) (iOS, Android, or both?): Android.

Device info: Device and Simulator Both (All Android versions).


MainActivity.java

public class MainActivity extends NavigationActivity {static Backbonebits b;public void addDefaultSplashLayout() {LinearLayout splash = new LinearLayout(this);Drawable splash_screen_bitmap = ContextCompat.getDrawable(getApplicationContext(),R.drawable.splashscreen);splash.setBackground(splash_screen_bitmap);    setContentView(splash);}@overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);MobileAds.initialize(this, new OnInitializationCompleteListener() {@overridepublic void onInitializationComplete(InitializationStatus initializationStatus) {}});b = new Backbonebits(this);}}

MainApplication.java

public class MainApplication extends NavigationApplication {private static CallbackManager mCallbackManager = CallbackManager.Factory.create();protected static CallbackManager getCallbackManager() {    return mCallbackManager;} @Override protected ReactGateway createReactGateway() {     ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {         @Override         protected String getJSMainModuleName() {             return "index";         }     };     return new ReactGateway(this, isDebug(), host); } @Override public boolean isDebug() {     return BuildConfig.DEBUG; }protected List<ReactPackage> getPackages() {  return Arrays.<ReactPackage>asList(        new MainReactPackage(),        new FBSDKPackage(mCallbackManager),  );} @Override public List<ReactPackage> createAdditionalReactPackages() {     return getPackages(); }}

App.js

import React, { Component } from 'react';import {Platform} from 'react-native';import { Navigation } from 'react-native-navigation'import TermsOfUseController from "./app/routes/TermsOfUseController"import Utility from './app/config/Utility';const registerScreen = (name, component, styles) => {component.navigatorStyle = {...defaultNavigatorStyles,...styles};Navigation.registerComponent(name, () => component)}function registerAllScreens() {registerScreen('MyApp.LoginController', LoginController, {})}registerAllScreens();User.loggedInUser((user) => {User.addSignOutListner()var screenName = 'MyApp.LoginController';if (user) {if (user.id != 0 && user.id != undefined) {Utility.isFirstTimeLaunch = truescreenName = 'MyApp.HomeScreenController'; // User Already logged in}else {Utility.isFirstTimeLaunch = truescreenName = 'MyApp.LoginController'; // Not Logged in}}});Navigation.events().registerAppLaunchedListener(() => {Navigation.setRoot({  root: {    stack: {      children: [{        component: {          name: screenName,          passProps: { ...Navigation }        }      }],      options: {        topBar: {          visible: false        },      }    }  }});});});

`componentDidMount()` function is not called after navigation

$
0
0

I am using stackNavigator for navigating between screens. I am calling two API's in componentDidMount() function in my second activity. When i load it first time, it gets loaded successfully. Then i press back button to go back to first activity. Then, if i am again going to second activity, the APIs are not called and I get render error. I am not able to find any solution for this. Any suggestions would be appreciated.

Viewing all 28463 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>