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

is there any DateTimePicker which renders common UI for both android and ios?

$
0
0

All the DateTimePickers I have come across as of now, have different UI for android and ios. This is one of the examples for that

But I would like to have same UI(I prefer android UI) in both Platforms.

Is it possible to have such a common UI?


Requiring unknown module "499" error in React Native

$
0
0

enter image description here

I am getting this error. I have tried running npm install multiple times but this is still there, how to get this worked?

problem in showing heads-up notification on foreground and background

$
0
0

I have a react-native app and I intended to show notification after receiving a message. For this perpuse, I have used nativeModule. I want to show notification pop up in both background and foreground. unfortunatly, notification has been shown only on status bar and notification drawer. based on document for having heads-up notification I should use fullScreenIntent, but by adding fullScreenIntent, every time notification has come and app is in foreground,not only did app restart, but also i cant see notification pop up.

this is my code in my module

public void scheduleNotification(Notification notification) {      Intent notificationIntent = new Intent(mContext, NotificationReceiver.class);      notificationIntent.putExtra(NotificationReceiver.NOTIFICATION_ID, 1);      notificationIntent.putExtra(NotificationReceiver.NOTIFICATION, notification);      PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);      long futureInMillis = SystemClock.elapsedRealtime();      AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(mContext.ALARM_SERVICE);      assert alarmManager != null;      alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, futureInMillis, pendingIntent);  }  public Notification getNotification(String shenaseGhabz, String shenasePardakht) {      String notificationBody = mContext.getResources().getString(R.string.bill_payment);      Intent intent = new Intent(mContext, MainActivity.class);      intent.putExtra("SHENASE_GHABZ", shenaseGhabz);      intent.putExtra("SHENASE_PARDAKHT", shenasePardakht);      TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);      stackBuilder.addNextIntentWithParentStack(intent);      PendingIntent pendingIntent =              stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);      PendingIntent fullScreenIntent = PendingIntent.getActivity(getCurrentActivity(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);      NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext, default_notification_channel_id);      builder.setContentTitle(mContext.getResources().getString(R.string.app_name));      builder.setContentText(notificationBody);      builder.setSmallIcon(R.drawable.logo);      builder.setAutoCancel(true);      builder.setChannelId(NOTIFICATION_CHANNEL_ID);      builder.setColor(mContext.getResources().getColor(R.color.light_orange));      builder.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationBody));      builder.addAction(0, mContext.getResources().getString(R.string.pay), pendingIntent);      builder.setVisibility(Notification.VISIBILITY_PUBLIC);      builder.setPriority(Notification.PRIORITY_MAX);      builder.setDefaults(Notification.DEFAULT_ALL);      builder.setFullScreenIntent(fullScreenIntent, true);      return builder.build();  }

and this is my receiver

public void onReceive(Context context, Intent intent) {        NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context. NOTIFICATION_SERVICE ) ;        Notification notification = intent.getParcelableExtra( NOTIFICATION ) ;        if (android.os.Build.VERSION. SDK_INT >= android.os.Build.VERSION_CODES. O ) {            int importance = NotificationManager. IMPORTANCE_HIGH ;            NotificationChannel notificationChannel = new NotificationChannel( NOTIFICATION_CHANNEL_ID , "NOTIFICATION_CHANNEL_NAME" ,importance) ;            assert notificationManager != null;            notificationManager.createNotificationChannel(notificationChannel) ;        }        int id = intent.getIntExtra( NOTIFICATION_ID , 0 ) ;        assert notificationManager != null;        notificationManager.notify(id , notification) ;    }

Expo or React Native: How to tint the entire screen or just a portion even if app isn't active

$
0
0

I'm looking for a way to tint the user's screen a certain shade, and change this tint overtime. (Think F.lux or Night Shift or any number of currently available blue light reducers). Is there any way to do this with React Native and/or Expo? I know iOS doesn't allow users to do this without Jailbreaking, but I believe this could be possible for Android at least? Thank you for your time.

React Native Expo project not running on Android Emulator

$
0
0

I'm new in React Native, I just setup a project with Expo & I already have android studio install. I run npm start and android emulator is already running. Now, in Metro Bundler when I click Run on Android device/emulator it simply give an error Couldn't start project on Android: The system cannot find the path specified. I also have added correct ANDROID_HOME variable to C:\Users\User Name\AppData\Local\Android\Sdk

Shadows improperly displayed in React Native application

$
0
0

I am currrently developing React Native application for both Android and iOS and I have encountered behaviour where shadows are improperly displayed on test device. Shadows look fine in Android emulator, however, when I build APK and upload it to test device, the shadows don't display properly anymore. The code working in emulator and code in built apk differ only in api url.

Shadows are set like this:

shadowOffset: {  width: 3,  height: 3,},shadowColor: Color.BLACK, // Resolves to #000000shadowOpacity: 1,elevation: 2,backgroundColor: Color.TRANSPARENT // Resolves to #0000

Below I attach also the look on emulator (desired):

Should be

and look on test device:

enter image description here

Appreciate any ideas on where to look for possible fix.

I am using React Native 0.63.1 and testing on device with Android 10.

Is it possible for Android to trigger an internal function of a React Native application without it running?

$
0
0

I have an application in React Native, I created a function to run in bg to be looking for the location of a user to make a route calculation in the end. I would like to know if it is possible to make Android somehow open a thread to run the app and with that this function will be triggered at a certain time.PS: The concept of the app is all offline first.

How do I make fs work, I've tried so many options but I can not make it work

$
0
0

For react native, I am trying to use fs. It says

While trying to resolve module `fs` from file `/Users/bbq/project/app/screens/folder.js`, the package `/Users/bbq/project/node_modules/fs/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/bbq/project/node_modules/fs/index.js`. Indeed, none of these files exist:

This is my code:

const fs = require('fs').promises;async function readFile(filePath) {  try {    const data = await fs.readFile(filePath);    console.log(data.toString());  } catch (error) {    console.error(`Got an error trying to read the file: ${error.message}`);  }}

What to do?


React-Native can't connect to online server only in Android

$
0
0

I have problems in connecting to the online server with my React Native only on Android side. When I make the Login request, which is tested to be functioning, it gives me error 500 of wrong credencials.

Api.js

export default {  oath_url: 'https://myserverdomain.it',  res_url: 'https://myserverdomain.it', };

Authentication.js

export function* requestLogin(action) { try {   const { email, password } = action.payload;   console.log(`requestLogin email:${email},password:${password}`);   const params = {     email,     password,   };   const response = yield call(api.post, '/login', params, {});  //The endpoint is the same of the function on my server side   console.log(`response: ${JSON.stringify(response.data)}`);   yield put(AuthenticationActions.requestLoginSuccess(response.data)); } catch (err) {   console.log(err);   yield put(AuthenticationActions.requestLoginFailure()); }}

Is there something that I should add to make it work also on Android? Thanks.

Exception thrown while unbinding IllegalArgumentException: Service not registered

$
0
0

I have a react native application that needs to open a native android activity.

package com.myappnative.stripe;import com.stripe.android.CustomerSession;import com.facebook.react.bridge.Callback;import com.facebook.react.bridge.ReactApplicationContext;import com.facebook.react.bridge.ReactContextBaseJavaModule;import com.facebook.react.bridge.ReactMethod;import android.content.Intent;public class StripeModule extends ReactContextBaseJavaModule {   public StripeModule(ReactApplicationContext reactContext) {       super(reactContext);   }   @Override   public String getName() {       return "Stripe";   }   @ReactMethod   public void startCustomerSession(String customerSecret, String ephemeralKey, Callback cb) {       try{            ReactApplicationContext context = getReactApplicationContext();            CustomerSession.initCustomerSession(                context,                new PreloadedEphemeralKeyProvider(ephemeralKey)            );            Intent intent = new Intent(context, HostActivity.class);            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);            context.startActivity(intent);             cb.invoke(null, "Loaded new Activity" );       }catch (Exception e){           cb.invoke(e.toString(), null);       }   }}

But when this code executes I see only a white screen.This is what I find in logcat output

2020-12-17 15:34:49.412 317-353/? D/goldfish-address-space: allocate: Ask for block of size 0x33b5802020-12-17 15:34:49.412 317-353/? D/goldfish-address-space: allocate: ioctl allocate returned offset 0x3fc402000 size 0x33d0002020-12-17 15:34:49.417 14640-14758/com.myappnative W/ReactNativeJS: 'Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https:// fb .me/react-unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n* If you\'re updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https:// fb .me/react-derived-state\n* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n\nPlease update the following components: %s', 'DatePicker'2020-12-17 15:34:49.433 317-353/? D/goldfish-address-space: allocate: Ask for block of size 0x33b5802020-12-17 15:34:49.433 317-353/? D/goldfish-address-space: allocate: ioctl allocate returned offset 0x3fb9a5000 size 0x33d0002020-12-17 15:34:49.447 317-353/? D/goldfish-address-space: allocate: Ask for block of size 0x33b5802020-12-17 15:34:49.447 317-353/? D/goldfish-address-space: allocate: ioctl allocate returned offset 0x3fb668000 size 0x33d0002020-12-17 15:34:49.485 524-2250/? I/ActivityTaskManager: START u0 {flg=0x10000000 cmp=com.myappnative/.stripe.HostActivity} from uid 101542020-12-17 15:34:49.512 524-565/? D/EventSequenceValidator: Transition from ACTIVITY_FINISHED to INTENT_STARTED2020-12-17 15:34:49.517 524-565/? D/EventSequenceValidator: Transition from INTENT_STARTED to INTENT_FAILED2020-12-17 15:34:49.561 524-2257/? W/ActivityTaskManager: Tried to set launchTime (0) < mLastActivityLaunchTime (5970973)2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_9 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_7 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_10 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_4 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_11 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_5 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_2 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_6 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_3 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_8 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_9 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_7 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_10 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_4 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_11 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_5 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_2 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_6 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_3 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.562 524-2257/? W/InputReader: Device virtio_input_multi_touch_8 is associated with display ADISPLAY_ID_NONE.2020-12-17 15:34:49.880 317-353/? D/goldfish-address-space: allocate: Ask for block of size 0x9256802020-12-17 15:34:49.880 317-353/? D/goldfish-address-space: allocate: ioctl allocate returned offset 0x3fedb2000 size 0x9270002020-12-17 15:34:49.915 317-353/? D/goldfish-address-space: allocate: Ask for block of size 0x9256802020-12-17 15:34:49.915 317-353/? D/goldfish-address-space: allocate: ioctl allocate returned offset 0x3fe48b000 size 0x9270002020-12-17 15:34:49.945 317-353/? D/goldfish-address-space: allocate: Ask for block of size 0x9256802020-12-17 15:34:49.945 317-353/? D/goldfish-address-space: allocate: ioctl allocate returned offset 0x3fa16d000 size 0x9270002020-12-17 15:34:50.029 524-570/? I/ActivityTaskManager: Displayed com.myappnative/.stripe.HostActivity: +542ms2020-12-17 15:34:50.357 14640-14758/com.myappnative I/ReactNativeJS: Registered token successfully2020-12-17 15:34:55.423 1385-1426/? I/PeriodicStatsRunner: PeriodicStatsRunner.call():180 call()2020-12-17 15:34:55.423 1385-1426/? I/PeriodicStatsRunner: PeriodicStatsRunner.call():184 No submit PeriodicStats since input started.2020-12-17 15:34:55.511 14640-14935/com.myappnative W/ConnectionTracker: Exception thrown while unbinding    java.lang.IllegalArgumentException: Service not registered: lu@ba64a86        at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1757)        at android.app.ContextImpl.unbindService(ContextImpl.java:1874)        at android.content.ContextWrapper.unbindService(ContextWrapper.java:792)        at ci.f(:com.google.android.gms.dynamite_measurementdynamite@204516104@20.45.16 (150800-0):1)        at ci.d(:com.google.android.gms.dynamite_measurementdynamite@204516104@20.45.16 (150800-0):2)        at lv.E(:com.google.android.gms.dynamite_measurementdynamite@204516104@20.45.16 (150800-0):9)        at lf.a(:com.google.android.gms.dynamite_measurementdynamite@204516104@20.45.16 (150800-0):3)        at ef.run(:com.google.android.gms.dynamite_measurementdynamite@204516104@20.45.16 (150800-0):3)        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)        at java.util.concurrent.FutureTask.run(FutureTask.java:266)        at iy.run(:com.google.android.gms.dynamite_measurementdynamite@204516104@20.45.16 (150800-0):5)

I assume that the activity is not completely loading because of this IllegalArgumentException. Also if I don't include the FLAG_ACTIVITY_NEW_TASK it does not load at all. I'm not sure if that is related. Why is my custom Activity not loading?

React Native app does not attempt to connect to Metro Bundler in debug mode

$
0
0

I have been maintaining an app with React Native v0.59.9 installed. Over the past month I have been able to run iOS builds but am now having issues with the Android version in debug mode. It appears the app is ignoring the Metro Bundler entirely. I run react-native run-android --variant=variantnameDebug to install the app on a dev phone over USB.

The app builds and loads, however, upon booting it is not loading from the bundler. The green loading bar overlay in the app does not appear and the bundler window in the terminal does not show any indication that the device is trying to connect to it. Furthermore, if I close the bundler on my machine and restart the app, it still boots as before. Finally, if the app encounters an error, the red crash screen does not appear and the app crashes just as a native app would. This almost feels like it is running a release build with none of the RN development components.

Another odd thing is the image assets are not loading. This caused me to try generating a debug bundle and specify the assets directly explicitly:

react-native bundle --platform android --dev true --entry-file index.android.js  --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest assets/

No luck. Based on another suggestion, I tried adding android:usesCleartextTraffic="true" to my manifest to no avail.

Searching the web gives many results for this common problem. I'm very familiar with this issue but this appears to be something different.

Any help is greatly appreciated.

Native module RNC_AsyncSQLiteDBStorage tried to override AsyncStorageModule

$
0
0

java.lang.IllegalStateException: Native module RNC_AsyncSQLiteDBStorage tried to override AsyncStorageModule. Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true. This error may also be present if the package is present only once in getPackages() but is also automatically added later during build time by autolinking. Try removing the existing entry and rebuild.

MainApplication.java

@Override    protected List<ReactPackage> getPackages() {      @SuppressWarnings("UnnecessaryLocalVariable")      List<ReactPackage> packages = new PackageList(this).getPackages();      // Packages that cannot be autolinked yet can be added manually here, for example:      // packages.add(new MyReactNativePackage());      return packages;    }

Register/index.js

import React, {useState} from 'react';import {StyleSheet, View, ScrollView} from 'react-native';import {Button, Gap, Header, Input, Loading} from '../../components'; import {colors, storeData, useForm} from '../../utils';import {Fire} from '../../config';import {showMessage} from 'react-native-flash-message';const Register = ({navigation}) => { const [form, setForm] = useForm({fullName: '',profession: '',email: '',password: '',  });    const [loading, setLoading] = useState(false);   const onContinue = () => {     console.log(form);     const data = {    fullName: form.fullName,    profession: form.profession,     email: form.email,    };     navigation.navigate('UploadPhoto', data);// setLoading(true);// Fire.auth()//   .createUserWithEmailAndPassword(form.email, form.password)//   .then((success) => {//     setLoading(false);//     setForm('reset');//     const data = {//       fullName: form.fullName,//       profession: form.profession,//       email: form.email,//     };//     Fire.database()//       .ref('users/'+ success.user.uid +'/')//       .set(data);//     storeData('user', data);//     navigation.navigate('UploadPhoto', data);//     console.log('register success:', success);//   })//   .catch((error) => {//     const errorMessage = error.message;//     setLoading(false);//     showMessage({//       message: errorMessage,//       type: 'default',//       backgroundColor: colors.error,//       color: colors.white,//     });//     console.log('error:', error);//   });          };  return (<><View style={styles.page}><Header onPress={() => navigation.goBack()} title="Daftar Akun" /><View style={styles.content}><ScrollView showsVerticalScrollIndicator={false}><Input          label="Full Name"          value={form.fullName}          onChangeText={(value) => setForm('fullName', value)}        /><Gap height={24} /><Input          label="Pekerjaan"          value={form.profession}          onChangeText={(value) => setForm('profession', value)}        /><Gap height={24} /><Input          label="Email"          value={form.email}          onChangeText={(value) => setForm('email', value)}        /><Gap height={24} /><Input          label="Password"          value={form.password}          onChangeText={(value) => setForm('password', value)}          secureTextEntry        /><Gap height={40} /><Button title="Continue" onPress={onContinue} /></ScrollView></View></View>  {loading && <Loading />}</>    ); }; export default Register;   const styles = StyleSheet.create({   page: {backgroundColor: colors.white, flex: 1},    content: {padding: 40, paddingTop: 0},   });

UploadPhoto/index.js

  import React, {useState} from 'react';import {StyleSheet, Text, View, Image, TouchableOpacity} from 'react-native';import {IconAddPhoto, ILNullPhoto, IconRemovePhoto} from '../../assets';import {Header, Link, Button, Gap} from '../../components';import {colors, fonts} from '../../utils';import {launchImageLibrary} from 'react-native-image-picker';import {showMessage} from 'react-native-flash-message';export default function index({navigation, route}) {const {fullName, profession, email} = route.params;console.log('fullName:', fullName)console.log('profession:', profession)console.log('email:', email)const [hasPhoto, setHasPhoto] = useState(false);const [photo, setPhoto] = useState(ILNullPhoto);const getImage = () => {launchImageLibrary({}, (response) => {  console.log('response:', response);  if (response.didCancel || response.error) {    showMessage({      message: 'oops, sepertinya anda tidak memilih fotonya?',      type: 'default',      backgroundColor: colors.error,      color: colors.white,    });  } else {    const source = {uri: response.uri};    setPhoto(source);    setHasPhoto(true);    }  }); };return (<View style={styles.page}><Header title="Upload Photo" /><View style={styles.content}><View style={styles.profile}><TouchableOpacity style={styles.avatarWrapper} onPress={getImage}><Image source={photo} style={styles.avatar} />        {hasPhoto && <IconRemovePhoto style={styles.addPhoto} />}        {!hasPhoto && <IconAddPhoto style={styles.addPhoto} />}</TouchableOpacity><Text style={styles.name}>Ferdiansyah</Text><Text style={styles.profession}>Programmer</Text></View><View><Button        disable={!hasPhoto}        title="Upload and Continue"        onPress={() => navigation.replace('MainApp')}      /><Gap height={30} /><Link        title="Skip for this"        align="center"        size={16}        onPress={() => navigation.replace('MainApp')}      /></View></View></View>);} const styles = StyleSheet.create({  page: {flex: 1, backgroundColor: colors.white},  content: {paddingHorizontal: 40,paddingBottom: 64,flex: 1,justifyContent: 'space-between',}, profile: {alignItems: 'center',flex: 1,justifyContent: 'center', }, avatar: {width: 110, height: 110, borderRadius: 110 / 2}, avatarWrapper: {width: 130,height: 130,borderWidth: 1,borderColor: colors.border,borderRadius: 130 / 2,alignItems: 'center',justifyContent: 'center', },    addPhoto: {position: 'absolute', bottom: 8, right: 6},  name: {fontSize: 24,color: colors.text.primary,fontFamily: fonts.primary[600],textAlign: 'center', }, profession: {fontSize: 18,fontFamily: fonts.primary.normal,textAlign: 'center',color: colors.text.secondary,marginTop: 4, }, });

Backend framework choices for React Native

$
0
0

I want to develop an android app that is based on server-client system. I want to develop both backend and android client. It's 2020 and there has already many frameworks developed to provide server side missions to programs.

My question is

What are the trending backend technologies in android world (from database to REST API frameworks), with reasons? For now, I have 2 framework/library on my mind. Spring and Node.js. Google Firebase are also in that list.

I also have another question

Suppose that I made a backend project and want to deploy it on a real server (development made on localhost). What choices should be made ? For example, I made my development on Mysql and Springboot framework, should that server provide support for MySql and Java ? What is the procedure to deploy both database and backend application ?

Thanks.

Why is my React Native app extremly slow (running on Expo)

$
0
0

I can't tell you more, the title is self explanatory.

All I can say is that my app is using react-navigation v5 and I have stack navigators. When I run Debug JS remotely I don't get any lag but as soon as I disable the debug, it becomes a nightmare even with simple texts and views.

Should I use InteractionManager, useMemo or stuff like that?

Thanks to anyone who can help help me.

PS: I only get lags on Android.

React Native Android WebView How to disable horizontal scroll?

$
0
0

I have a problem with webview and scrolling. I want to disable all scrolling. I used scrollEnabled, for IOS it works fine. But for android no property like this exists. I tried a lot of scripts but nothing works.

At first look everything seems ok but if user swipes to right side then the text/div moves outside of screen.

how it looks like when it is ok

and this is what happened

how it looks like when user will swipe to side

this is my webview:

<WebView  bounces={false}  ref={(element) => { this.webViewRef = element; }}  javaScriptEnabled  scalesPageToFit={false}  onShouldStartLoadWithRequest={this._onShouldStartLoadWithRequest}  style={{    height: this.state.webViewHeight,  }}  scrollEnabled={false}  source={{    html: `<!DOCTYPE html><html><head>${injectedStyle(platformStyles.fontSizes.base || 16, webViewWidth)}</head><body><div id="baseDiv" class="ex1">${content}</div>              ${injectedJS}</body></html>    `,    baseUrl: 'http://s3.eu-central-1.amazonaws.com',  }}  onNavigationStateChange={this._processNavigationStateChange}  automaticallyAdjustContentInsets={false}/>

and i tried to add a style like this ( overflow: 'hidden' but its doesn't work):

    const injectedStyle = (fontSize, widhtPlatform) => `<style type="text/css">    ...    body {            display: flex;            overflow: hidden;            background-color: orange;    ...        }    div.ex1 {      overflow: hidden;  background-color: coral;  border: 1px solid blue;    ...    }</style>`;

and JS to disable scroll:

const injectedJS = `<script>    var scrollEventHandler = function()      {        window.scroll(0, window.pageYOffset)      }    document.addEventListener('scroll', scrollEventHandler, false);    document.getElementById('scrollbar').style.display = 'block';    document.body.style.overflow = 'hidden';</script>`;

We use RN:

react-native-cli: 2.0.1

react-native: 0.53.3


Getting Error on Building APK - Android Studio

$
0
0

I am newbie and trying to build an APK in android studio. Getting the follwing errorError : Android Resource Packaging:[Project Name] D:\react-app\Android\AppError : Android Resource Packaging:[Project Name] src\main\AndroidManifest.xml:45: error:Error:no resource found that matches the given name (at 'label' with value '@string/App_name).

there are approx 9 errors showing.please help to resolve the problem.

React Native Can't open url: intent://photos.app.goo.gl/ in apps webview

$
0
0

I'm opening a url inside react-native-webview. The URL is opening fine. But the problem is if I tap on some component in webview it will return me "intent://photos.app.goo.gl/HvTckEDkdidAhTvC6#Intent;package=com.google.android.gms;xxxxxxxxx" type url. I want to open it in webview only. Its working fine in iOS. For android in some links its working and some links it won't. Any help much appreciated.

How to reduce audio data recorded with ENCODING_PCM_16BIT and sample rate 8000 Hz?

$
0
0

My goal is to reduce the audio data size generated by the react-native-recording.

The expected result:The audio file size should be between 5200 bytes to 5400 bytes per 1 seconds of audio / Opus Voice bit rate 5.17 KiB with sampling rate 8 kHz.

The actual result:The audio file size is 3 times the expected result. For example recording this word A guest for Mr. Jerry / 1.6 seconds of audio will have a data size roughly 28,000 bytes.

Important

I plan to write custom native module to achieve this goal. If you like, feel free to leave a link for me to read.

TL:DR

My end goal is to send the audio data through WebSocket. I deliberately remove the WebSocket.

Steps to reproduce:

  1. Add listener
  let audioInt16: number[] = [];  let listener;  React.useEffect(() => {    // eslint-disable-next-line react-hooks/exhaustive-deps    listener = Recording.addRecordingEventListener((data: number[]) => {      console.log('record', data.length);      // eslint-disable-next-line react-hooks/exhaustive-deps      audioInt16 = audioInt16.concat(data);    });    return () => {      listener.remove();    };  });
  1. Record audio
  const startAsync = async () => {    await PermissionsAndroid.requestMultiple([      PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,    ]);    Recording.init({      bufferSize: 4096,      sampleRate: 8000,      bitsPerChannel: 16,      channelsPerFrame: 1,    });    Recording.start();  };
  1. Save audio
  const saveAudio = async () => {    const promise = await RNSaveAudio.saveWav(path, audioInt16);    console.log('save audio', promise, path);  };
  1. Play audio
  const playAudio = () => {    if (player.canPrepare || player.canPlay) {      player.prepare((err) => {        if (err) {          console.log(err);        }        console.log('play audio', player.duration);        player.play();      });    }  };

React Native - Define global buffer?

$
0
0

I'm trying to figure out if I can set a "global buffer" for my React Native App. The idea is that everytime a js function is called, it displays a rotating icon ("buffer").

Does anyone know a good way to do this ? Are there reliable packages to do this ?

Thanks !

'react-native-mathjax' not rendering for single backslash

$
0
0

I am using 'react-native-mathjax' to render math equations. 'react-native-mathjax' not able to render for single backslash. When I add double backslash in place of single backslash and four backslashes in place of double backslash in the equation given below, 'react-native-mathjax' renders the equation, is there any solution?

    import React from 'react';    import { View, Text } from 'react-native';    import MathJax from 'react-native-mathjax';    function Test() {            return (<View><MathJax                        html={<p><span class="math-tex">\(\begin{bmatrix} 2 &1 \\[0.3em] 3&4\\[0.3em] \end{bmatrix}\)</span></p>} // not rendering this eqation                    /></View>     );    }    export default Test;
Viewing all 29764 articles
Browse latest View live


Latest Images

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