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

Saving a photo taking a very long time

$
0
0

I want users to be able to take photos from within my app and have the photos save to their gallery (so that I can later view them in a photo-picker).

I have the following code from react-native-camera, it's basically the bare-bones demo code.

takePicture() {
    const options = { quality: 0.5, fixOrientation: false, width: 1920 };
    if (this.camera) {
      this.camera
        .takePictureAsync(options)
        .then(data => {
             this.saveImage(data.uri);
        })
        .catch(err => {
          console.error("capture picture error", err);
        });
    } else {
      console.error("No camera found!");
    }
  }
}

To move the attachment, I am using react-native-fs, as follows (more basic demo-y code):

const dirHome = Platform.select({
  ios: `${RNFS.DocumentDirectoryPath}/Pictures`,
  android: `${RNFS.ExternalStorageDirectoryPath}/Pictures`
});

const dirPictures = `${dirHome}/MyAppName`;

saveImage = async filePath => {
    try {
      // set new image name and filepath
      const newImageName = `${moment().format("DDMMYY_HHmmSSS")}.jpg`;
      const newFilepath = `${dirPictures}/${newImageName}`;
      // move and save image to new filepath
      const imageMoved = await this.moveAttachment(filePath, newFilepath);
      console.log("image moved: ", imageMoved);
    } catch (error) {
      console.log(error);
    }
  };

  moveAttachment = async (filePath, newFilepath) => {
    return new Promise((resolve, reject) => {
      RNFS.mkdir(dirPictures)
        .then(() => {
          RNFS.moveFile(filePath, newFilepath)
            .then(() => {
              console.log("FILE MOVED", filePath, newFilepath);
              resolve(true);
            })
            .catch(error => {
              console.log("moveFile error", error);
              reject(error);
            });
        })
        .catch(err => {
          console.log("mkdir error", err);
          reject(err);
        });
    });
  };

When taking a photo, this code executes and prints that the image has been moved within a couple of seconds. But, when I look into the built in Gallery App on the device, it often takes several minutes for the image to finally load. I've tried this across many different devices, both emulated and physical... am I doing something wrong? Thanks!


Windows/React Native can't create ADB Bridge error

$
0
0

I'm trying to run a React Native App on Windows but I'm getting a weird error.

What went wrong: Execution failed for task ':app:installDebug'.

com.android.builder.testing.api.DeviceException: Could not create ADB Bridge. ADB location: C:\Users\Username\AppData\Local\Android\Sdk\platform-tools\adb.exe

I've seen similar solutions to this problem but they seemed geared towards Mac Users. If anyone can give me a working solution that will be greatly appreciated.

Thank you in Advance.

React-Native app is crash in some Android phones

$
0
0

My React-Native app is crashing in some Samsung devices which has OS version 9. It is working fine in all other devices. Application's React-Native version is 0.57.5. Here I am uploading a screenshots. For Samsung Exynos 7870, which is working fine and For Samsung A30, in which I am getting crash issue.

enter image description here

Here is the scenario: I installed the app, Splash screen is launched and then it is crash.

Android studio crash log:

2019-11-04 15:35:28.451 13820-14072/com.openchair E/SoLoader: Error when loading lib: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit lib hash: 38a149cf3f94c06f35444ea1c5280541 search path is /data/app/com.openchair-RKWR45KUxyRawC30KCnIFQ==/lib/arm64 2019-11-04 15:35:28.451 13820-14072/com.openchair E/SoLoader: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit 2019-11-04 15:35:28.451 13820-14072/com.openchair E/SoLoader: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit 2019-11-04 15:35:28.452 13820-14072/com.openchair E/SoLoader: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit 2019-11-04 15:35:28.452 13820-14072/com.openchair E/SoLoader: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit 2019-11-04 15:35:28.453 13820-14072/com.openchair E/AndroidRuntime: FATAL EXCEPTION: Thread-8 Process: com.openchair, PID: 13820 java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:703) at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:564) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:500) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:455) at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:18) at com.facebook.react.bridge.NativeMap.(NativeMap.java:19) at com.facebook.react.bridge.JSCJavaScriptExecutorFactory.create(JSCJavaScriptExecutorFactory.java:21) at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:917) at java.lang.Thread.run(Thread.java:764)

Can you please help me with this? Thank you in advance.

React-Native app is crashing in some Android phones

$
0
0

My React-Native app is crashing in some Samsung devices which has OS version 9. It is working fine in all other devices. Application's React-Native version is 0.57.5. Here I am uploading a screenshots. For Samsung Exynos 7870, which is working fine and For Samsung A30, in which I am getting crash issue.

enter image description here

Here is the scenario: I installed the app, Splash screen is launched and then it is crashing.

Android studio crash log:

2019-11-04 15:35:28.451 13820-14072/com.openchair E/SoLoader: Error when loading lib: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit lib hash: 38a149cf3f94c06f35444ea1c5280541 search path is /data/app/com.openchair-RKWR45KUxyRawC30KCnIFQ==/lib/arm64
2019-11-04 15:35:28.451 13820-14072/com.openchair E/SoLoader: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
2019-11-04 15:35:28.451 13820-14072/com.openchair E/SoLoader: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
2019-11-04 15:35:28.452 13820-14072/com.openchair E/SoLoader: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
2019-11-04 15:35:28.452 13820-14072/com.openchair E/SoLoader: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
2019-11-04 15:35:28.453 13820-14072/com.openchair E/AndroidRuntime: FATAL EXCEPTION: Thread-8
    Process: com.openchair, PID: 13820
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.openchair/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:703)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:564)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:500)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:455)
        at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:18)
        at com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:19)
        at com.facebook.react.bridge.JSCJavaScriptExecutorFactory.create(JSCJavaScriptExecutorFactory.java:21)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:917)
        at java.lang.Thread.run(Thread.java:764)

Can you please help me with this? Thank you in advance.

How to create an Android swipe view using React Native?

$
0
0

I'm interested in creating an Android swipe view control that looks like this in my React Native app:

Are there mature libraries/APIs out there that will help me do this in React Native, or would I have to write a Java module that accessed platform APIs?

(If I'd have to write a Java module, maybe lend me some tips/advice on how that would work out. i.e. assuming I still want to write the pages with JavaScript even if the swipe view is handled in Java, how would I load/display the React component for each tab's page from Java?)

edit: ViewPager looks like just what I'm looking for, but keeping this question open in case there are any higher-starred libs out there that support this?

Appstate keep on getting change in React native in Android

$
0
0

I am working on React native project and there I am taking location permissions. Also I have to track location permissions always like if user has given permission access after install the application and then after sometime user goes to the app settings in device settings and disable/revoked the permissions. Again once app comes from background to foreground, I have to check permission based on that, Needs to show the messages.

So that, I am using Appstate. But, In Android strangely, After installed the application, If user denied the permission with "Dont show again" checkbox, Then Appstate getting keep on changing with background and active always. It is keep on loop.

componentDidMount = async () => {
    AppState.addEventListener('change', this.handleAppStateChange);
  };

  componentWillUnmount() {
    AppState.removeEventListener('change', this.handleAppStateChange);
    Geolocation.clearWatch(this.watchID);
  }

  handleAppStateChange = async nextAppState => {
    const {appState} = this.state;
    console.log('nextAppState -->', nextAppState);
    console.log('appState -->', appState);
    if (appState === 'active') {
      // do this
      this.showLoader();
      await this.requestAndroidLocationPermission();
    } else if (appState === 'background') {
      // do that
    } else if (appState === 'inactive') {
      // do that other thing
    }

    this.setState({appState: nextAppState});
  };

requestAndroidLocationPermission = async () => {
    try {
      const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
        {},
      );
      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        this.getLatitudeLongitude();
      } else if (granted === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) {
        this.hideLoader();
        this.setState({
          errorMessage: 'Location permission is denied',
          isLoading: false,
        });
      } else {
        this.hideLoader();
        this.requestAndroidLocationPermission();
      }
    } catch (err) {
      console.warn(err);
    }
  };

It is keep on printing (loop) after denied permission with Don't show again

appState --> active
nextAppState --> background
appState --> active
nextAppState --> background
appState --> active
nextAppState --> background
appState --> active

It goes on and never stop.

How to handle this? Any suggestions?

swiper stope. It's not moving

$
0
0

I use react-native-swiper in my home screen, fist time I installed it basically: npm i --save react-native-swiper then I got an error with viewpagerandroid and the new version of RN: 0.61.2. I got that I have to install another version of swiper : npm i --save react-native-swiper@nightly and then no error but my swiper dont work: buttons are clockable but images don't swipe and i can't swipe it manually. this is my code:

<Swiper
    index={this.state.firstSlide}
    autoplay={true}
    autoplayTimeout= {2}
    loop={true}
    style={Styles.slider}
    showsButtons={true}
    showsPagination={true}
    buttonTextStyle={{color:'#9e9e9e', fontSize:24}}
  >



{this.state.slides.map((item, key) => {
      return(
          <ImageBackground
            key={key}
            style={Styles.slide1}
            source={{uri: 'https://www.website.com/folder1/api/../' + item.path}}
            resizeMode={'cover'}
            blurRadius={2}
            opacity= {0.7}
            >
              <Image
                source={{uri: 'https://www.website.com/folder1/api/../' + item.path}}
                style={Styles.imageStyle}
                resizeMode={'contain'}
              />
          </ImageBackground>
      );
  })}

  </Swiper>

ps. this code work for me in other project with other version of RN: 0.59.1 and R-N-Swiper when I try to use juste an easy example:

<Swiper style={styles.wrapper} showsButtons={true}>
    <View style={styles.slide1}>
      <Text style={styles.text}>Hello Swiper</Text>
    </View>
    <View style={styles.slide2}>
      <Text style={styles.text}>Beautiful</Text>
    </View>
    <View style={styles.slide3}>
      <Text style={styles.text}>And simple</Text>
    </View>
  </Swiper>

button are clickable but this time pagination works to but only the last view is shown!

react-native run-android fails with error

$
0
0

getting the following errors when running the command: <code>react-native run-android</code>

i'm getting the following errors in my console.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong: Execution failed for task ':react-native-video:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • 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.

2: Task failed with an exception.

  • What went wrong: Execution failed for task ':react-native-firebase:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 10s 151 actionable tasks: 13 executed, 138 up-to-date error Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.


Change package name for Android in React Native

$
0
0

I used react-native init MyApp to initialise a new React Native app. This created among others an Android project with the package com.myapp.

What's the best way to change this package name, for example to: com.mycompany.myapp?

I tried changing it in AndroidManifest.xml but it created other errors, so I'm assuming it's not the way.

Any idea?

Accessing multiple schema to add data on properties

$
0
0

I am trying to add array data on realm objects, but whenever I try to add data my app crashes without giving any error. I am using fetched data and passing one by one item to each object which has been declared.

import React, { Component } from 'react'
import { Alert, View, Text, TouchableOpacity } from 'react-native';
import { withNavigation } from 'react-navigation';
var Realm = require('realm');
const mostListened = {
    name: 'mostListened',
    properties: {
        id: 'int',
        child_image_url: 'string',
        child_name: 'string',
        children_who_staredA: 'string',
        children_who_staredB: 'string',
        children_who_staredC: 'string',
        children_who_staredD: 'string',
        duration: 'int',
        number_of_stars: 'int',
        number_of_streams: 'int',
        title: 'string',
    }
}
const mostLiked = {
    name: 'mostLiked',
    properties: {
        id: 'int',
        child_image_url: 'string',
        child_name: 'string',
        children_who_staredA: 'string',
        children_who_staredB: 'string',
        children_who_staredC: 'string',
        children_who_staredD: 'string',
        duration: 'int',
        number_of_stars: 'int',
        number_of_streams: 'int',
        title: 'string',
    }
}
const trendingPodcasts = {
    name: 'trendingPodcasts',
    properties: {
        id: 'int',
        child_image_url: 'string',
        child_name: 'string',
        children_who_staredA: 'string',
        children_who_staredB: 'string',
        children_who_staredC: 'string',
        children_who_staredD: 'string',
        duration: 'int',
        number_of_stars: 'int',
        number_of_streams: 'int',
        title: 'string',
    }
}

class AddArrayData extends Component {

    static navigationOptions = {
        header: null
    }
    constructor(props) {
        super(props);
        this.state = {
            mostListenedData: [],
            trendingPodcasts: [],
            mostLikedPodcasts: [],
        }
    }
    componentDidMount() {
        fetch('abc')
            .then((response) => response.json())
            .then((responseJson) => {
                this.setState({ mostListenedData: { data: responseJson.data } })
            });
        fetch('abc')
            .then((response) => response.json())
            .then((responseJson) => {
                this.setState({ mostLikedPodcasts: { data: responseJson.data } })
            });
        fetch('abc')
            .then((response) => response.json())
            .then((responseJson) => {
                this.setState({ trendingPodcasts: { data: responseJson.data } })
            });
    }
    addStudentData = () => {
        console.log(this.state.mostListenedData, this.state.mostLikedPodcasts, this.state.trendingPodcasts);
        Realm.open({ schema: [mostListened, mostLiked, trendingPodcasts], schemaVersion: 11 })
            .then(realm => {
                realm.write(() => {
                    for (let i = 0; i <= this.state.mostListenedData.data.podcasts.length; i++) {
                        realm.create('mostListened', {
                            id: i,
                            child_image_url: this.state.mostListenedData.data.podcasts[i].child_image_url,
                            child_name: this.state.mostListenedData.data.podcasts[i].child_name,
                            children_who_staredA: this.state.mostListenedData.data.podcasts[i].children_who_stared[0],
                            children_who_staredB: this.state.mostListenedData.data.podcasts[i].children_who_stared[1],
                            children_who_staredC: this.state.mostListenedData.data.podcasts[i].children_who_stared[2],
                            children_who_staredD: this.state.mostListenedData.data.podcasts[i].children_who_stared[3],
                            duration: this.state.mostListenedData.data.podcasts[i].duration,
                            number_of_stars: this.state.mostListenedData.data.podcasts[i].number_of_stars,
                            number_of_streams: this.state.mostListenedData.data.podcasts[i].number_of_streams,
                            title: this.state.mostListenedData.data.podcasts[i].title,
                        });
                        realm.create('mostLiked', {
                            id: i,
                            child_image_url: this.state.mostLikedPodcasts.data.podcasts[i].child_image_url,
                            child_name: this.state.mostLikedPodcasts.data.podcasts[i].child_name,
                            children_who_staredA: this.state.mostLikedPodcasts.data.podcasts[i].children_who_stared[0],
                            children_who_staredB: this.state.mostLikedPodcasts.data.podcasts[i].children_who_stared[1],
                            children_who_staredC: this.state.mostLikedPodcasts.data.podcasts[i].children_who_stared[2],
                            children_who_staredD: this.state.mostLikedPodcasts.data.podcasts[i].children_who_stared[3],
                            duration: this.state.mostLikedPodcasts.data.podcasts[i].duration,
                            number_of_stars: this.state.mostLikedPodcasts.data.podcasts[i].number_of_stars,
                            number_of_streams: this.state.mostLikedPodcasts.data.podcasts[i].number_of_streams,
                            title: this.state.mostLikedPodcasts.data.podcasts[i].title,
                        });
                        realm.create('trendingPodcasts', {
                            id: i,
                            child_image_url: this.state.trendingPodcasts.data.podcasts[i].child_image_url,
                            child_name: this.state.trendingPodcasts.data.podcasts[i].child_name,
                            children_who_staredA: this.state.trendingPodcasts.data.podcasts[i].children_who_stared[0],
                            children_who_staredB: this.state.trendingPodcasts.data.podcasts[i].children_who_stared[1],
                            children_who_staredC: this.state.trendingPodcasts.data.podcasts[i].children_who_stared[2],
                            children_who_staredD: this.state.trendingPodcasts.data.podcasts[i].children_who_stared[3],
                            duration: this.state.trendingPodcasts.data.podcasts[i].duration,
                            number_of_stars: this.state.trendingPodcasts.data.podcasts[i].number_of_stars,
                            number_of_streams: this.state.trendingPodcasts.data.podcasts[i].number_of_streams,
                            title: this.state.trendingPodcasts.data.podcasts[i].title,
                        });
                    }
                });
            })
            .catch(error => {
                console.log(error);
            });
        Alert.alert("Student Details Added Successfully.")
    }
    deleteAllData = () => {
        Realm.open({ schema: [mostListened, mostLiked, trendingPodcasts], schemaVersion: 11 })
            .then(realm => {
                realm.write(() => {
                    realm.deleteAll()
                });
            })
            .catch(error => {
                console.log(error);
            });
    }
    showStudentData = () => {
        Realm.open({ schema: [mostListened, mostLiked, trendingPodcasts], schemaVersion: 11 })
            .then(realm => {
                var mostListened = Array.from(realm.objects('mostListened'));
                this.state.mostListenedData = mostListened;
                this.setState({ mostListenedData: this.state.mostListenedData });
                console.warn(this.state.mostListenedData);
            })
            .catch(error => {
                console.log(error);
            });
    }
    render() {
        return (
            <View style={{ flex: 1 }}>
                <TouchableOpacity onPress={() => this.addStudentData()} activeOpacity={0.7} style={{ marginTop: 16, marginLeft: 32, marginRight: 32, justifyContent: 'center', alignItems: 'center', backgroundColor: 'orange', height: 30, width: '40%', alignSelf: 'center', borderRadius: 12 }} >
                    <Text style={{ color: '#fff', fontSize: 12, fontWeight: 'bold' }}>ADD STUDENT</Text>
                </TouchableOpacity>
                <TouchableOpacity onPress={() => this.showStudentData()} activeOpacity={0.7} style={{ marginTop: 16, marginLeft: 32, marginRight: 32, justifyContent: 'center', alignItems: 'center', backgroundColor: 'blue', height: 30, width: '40%', alignSelf: 'center', borderRadius: 12 }} >
                    <Text style={{ color: '#fff', fontSize: 12, fontWeight: 'bold' }}>SHOW STUDENT DATA</Text>
                </TouchableOpacity>
                <TouchableOpacity onPress={() => this.deleteAllData()} activeOpacity={0.7} style={{ marginTop: 16, marginLeft: 32, marginRight: 32, justifyContent: 'center', alignItems: 'center', backgroundColor: 'green', height: 30, width: '40%', alignSelf: 'center', borderRadius: 12 }} >
                    <Text style={{ color: '#fff', fontSize: 12, fontWeight: 'bold' }}>DELETE ALL DATA</Text>
                </TouchableOpacity>
            </View>
        );
    }
}
export default withNavigation(AddArrayData);

Please anybody could suggest that is this the right way to open multiple schemas and with the help of a write method storing data in the realm. I am new to the realm.

basic react native app not showing any text only white screen with app name on simulator

$
0
0

i am trying to run simple react native app. just text 'Hello World!', it's supposed to be my first app in react native. below is my simple app.js file

    /**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React from 'react';
import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
} from 'react-native';

import {
  Header,
  LearnMoreLinks,
  Colors,
  DebugInstructions,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

const App: () => React$Node = () => {
  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        <ScrollView
          contentInsetAdjustmentBehavior="automatic"
          style={styles.scrollView}>
          <Header />
          {global.HermesInternal == null ? null : (
            <View style={styles.engine}>
              <Text style={styles.footer}>Engine: Hermes</Text>
            </View>
          )}
          <View style={styles.body}>
            <View style={styles.sectionContainer}>
              <Text style={styles.sectionTitle}>Step One</Text>
              <Text style={styles.sectionDescription}>
                Edit <Text style={styles.highlight}>App.js</Text> to change this
                screen and then come back to see your edits.
              </Text>
            </View>
            <View style={styles.sectionContainer}>
              <Text style={styles.sectionTitle}>See Your Changes</Text>
              <Text style={styles.sectionDescription}>
                <ReloadInstructions />
              </Text>
            </View>
            <View style={styles.sectionContainer}>
              <Text style={styles.sectionTitle}>Debug</Text>
              <Text style={styles.sectionDescription}>
                <DebugInstructions />
              </Text>
            </View>
            <View style={styles.sectionContainer}>
              <Text style={styles.sectionTitle}>Learn More</Text>
              <Text style={styles.sectionDescription}>
                Read the docs to discover what to do next:
              </Text>
            </View>
            <LearnMoreLinks />
          </View>
        </ScrollView>
      </SafeAreaView>
    </>
  );
};

const styles = StyleSheet.create({
  scrollView: {
    backgroundColor: Colors.lighter,
  },
  engine: {
    position: 'absolute',
    right: 0,
  },
  body: {
    backgroundColor: Colors.white,
  },
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
    color: Colors.black,
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
    color: Colors.dark,
  },
  highlight: {
    fontWeight: '700',
  },
  footer: {
    color: Colors.dark,
    fontSize: 12,
    fontWeight: '600',
    padding: 4,
    paddingRight: 12,
    textAlign: 'right',
  },
});

export default App;

i started with react-native cli, https://facebook.github.io/react-native/docs/getting-started (React-Native CLI Quickstart) trying to run app on simulator with npx react-native run-ios but i can see only blank screen with app name on it..

enter image description here

..this happened with other basic apps i had created... what wrong or i am missing...

react-native yarn android cannot build

$
0
0

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 app:installDebug -PreactNativeDevServerPort=8081

  • What went wrong: A problem occurred evaluating project ':react-native-splash-screen'.

    Could not find method testImplementation() for arguments [junit:junit:4.12] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Error: resource style/Theme.AppCompat.Light.NoActionBar not found

$
0
0

I was working on an android app some time ago. I had to pause development for it for a while and when I tried to resume work, I found an error I didn't have before.

enter image description here

I have tried multiple things. First I reinstalled Android Studio, with the same results.

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.storev2.bexfy"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 212
        versionName "2.1.2"

        ndk {
            abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
        }
        renderscriptTargetApi 21
        renderscriptSupportModeEnabled true
        missingDimensionStrategy 'react-native-camera', 'general'
        multiDexEnabled true
    }
    signingConfigs {
        release {
            storeFile file("/Users/development/bexfy-satellite-mobile/android/keystores/bexfyappstore.keystore")
            keyAlias "bexfyappstore-key"
            storePassword "Llacuna11"
            keyPassword "Llacuna11"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk true  // If true, also generate a universal APK
            include 'x86', 'x86_64', 'arm64-v8a', 'armeabi-v7a', 'armeabi'
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
    compileOptions {
     targetCompatibility JavaVersion.VERSION_1_8
   }
}

dependencies {
    implementation project(':react-native-camera')
    compile project(":rncamerakit")
    compile project(':react-native-fast-image')
    compile project(':@react-native-community_async-storage')
    compile project(':react-native-video')
    compile project(':react-native-vector-icons')
    compile project(':react-native-orientation')
    compile project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    // implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" 
    // compile "com.android.support:support-v${rootProject.ext.supportLibVersion}"  
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

I've tried multiple things in order to make it work. If I uncomment compile "com.android.support:support-v${rootProject.ext.supportLibVersion}" it gives me the following error.

enter image description here

I've also tried modifying the <application> and <style> but with no result.

styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          package="com.storev2.bexfy">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />

    <!--<uses-permission android:name="android.permission.VIBRATE"/>-->



    <application
            android:name=".MainApplication"
            android:label="@string/app_name"
            android:icon="@mipmap/ic_launcher"
            android:allowBackup="false"
            android:theme="@style/AppTheme">
        <activity
                android:name=".MainActivity"
                android:label="@string/app_name"
                android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
                android:screenOrientation="portrait"
                android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

Any ideas for a fix to this?

React Native Android App crashing with "E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules"

$
0
0

Crash my app after install and config react-native-maps and @react-native-firebase/app in existing projects.

Environment info

OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Memory: 2.08 GB / 11.90 GB
Binaries:
Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
SDKs:
Android SDK:
  API Levels: 23, 25, 26, 27, 28
  Build Tools: 23.0.1, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.1, 28.0.2, 28.0.3
  System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5900203
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4

Part of my app dependencies:

"@react-native-firebase/app": "^6.0.3",
"react-native-maps": "0.26.1",

Steps To Reproduce

I did a debug through the Aandroid studio and get following error

--------- beginning of crash 11-13 15:00:24.209 4709-4746/com.melk.android E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.melk.android, PID: 4709 java.lang.NoClassDefFoundError: com.google.android.gms.maps.GoogleMapOptions at com.airbnb.android.react.maps.AirMapManager.(AirMapManager.java:60) at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:40) at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:782) at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:184) at com.facebook.react.CoreModulesPackage.getModule(CoreModulesPackage.java:152) at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:122) at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:110) at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:188) at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:153) at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:148) at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:479) at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:466) at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:31) at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1054) at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1012) at com.facebook.react.ReactInstanceManager.access$1400(ReactInstanceManager.java:125) at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:972) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:26) at android.os.Looper.loop(Looper.java:148) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:225) at java.lang.Thread.run(Thread.java:818)

Reproducible sample code

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")

        classpath 'com.google.gms:google-services:4.2.0'
    }
}

Bottom tab bar moves up when keyboard opens in React Native

$
0
0

Without changing the android:windowSoftInputMode="adjustResize" to adjustPan i want to stop the bottom tab bar resizing.

<KeyboardAvoidingView> also not working as expected.

can anyone give solution.

I am using react-native-router-flux

"react": "^16.8.6", "react-native": "^0.59.2",


Can't add tflite model to React Native project

$
0
0

I have created a React Native project using Expo and have a fully functional converted tflite model from keras. I am trying to use the react-native-tensorflow-lite package API to recognize my model a JPEG picture.

NPM package for React Native Tensorflow lite I used the exact same template in my expo project, but for some reason the API cannot recognize the model.tflite file path. (See error message in image attachment). Red Error Screen

Below is a copy of how I tried to implement this API using the Expo-Assets library:

import {TFLiteImageRecognition} from 'react-native-tensorflow-lite';
import React, {Component} from "react";
import {Text, View, StyleSheet} from "react-native";
import {Asset} from "expo-asset";

//Assets
import Anna from '../../assets/images/anna.jpg';
import Model from '../../android/app/src/main/assets/converted_model.tflite';
import Labels from '../../android/app/src/main/assets/labels.txt';

class MyImageClassifier extends Component {

    constructor() {
        super();
        this.state = {};

        try {
            // Initialize TensorFlow Lite Image Recognizer
            this.tfLiteImageRecognition = new TFLiteImageRecognition({
                labels: Asset.fromModule(Labels).downloadAsync(),// Your label file in assets folder
                model: Asset.fromModule(Model).downloadAsync()  // Your tflite model in assets folder.
            })
        } catch (err) {
            alert(err)
        }
    }

    /*init (callback) {
        // do something async and call the callback:
        callback.bind(this)();
    }*/

    componentWillMount() {
        let imagePath = Asset.fromModule(require("../../assets/images/anna.jpg"));
        console.warn(imagePath);
        this.classifyImage().then(console.log("Image Classified!"));
    }

    async classifyImage() {
        try {
            const results = await this.tfLiteImageRecognition.recognize({
                image: Asset.fromModule(Anna).downloadAsync(),  // Your image path.
                inputShape: (1, 100, 100, 1), // the input shape of your model. If none given, it will be default to 224.
            });

            const resultObj = {
                name: "Name: " + results[0].name,
                confidence: "Confidence: " + results[0].confidence,
                inference: "Inference: " + results[0].inference + "ms"
            };
            this.setState(resultObj)

        } catch (err) {
            alert(err)
        }
    }

    componentWillUnmount() {
        this.tfLiteImageRecognition.close() // Must close the classifier when destroying or unmounting component to release object.
    }

    render() {
        return (
            <View style={styles.container}>
                <View>
                    <Text style={styles.results}>
                        {this.state.name}
                    </Text>
                    <Text style={styles.results}>
                        {this.state.confidence}
                    </Text>
                    <Text style={styles.results}>
                        {this.state.inference}
                    </Text>
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        paddingTop: 15,
        backgroundColor: '#fff',
    },
    results: {
        fontSize: 22,
        fontFamily: "serif",
        textAlign: 'center'
    }
});

export default MyImageClassifier;

I have tested that the file paths accurately point towards the relevant files, so that is definitely not the issue here. I have also validated that my TFLite model can make predictions when passed in input data of the correct shape.

Here is the video I used as a reference to aid me implment the API Geeky Ants Tensorflow lite into React Native.

Any help would be much appreciated.

AppCenter's responsibility

$
0
0

I'm trying to figure out the CI portion that provided by AppCenter. I've implemented CodePush for my app and please correct me if my understanding is wrong.

  1. We build the native android app and generate a signed apk.
  2. Release the generated signed apk to playstore
  3. execute command to upload bundle appcenter codepush release-react -a <owner>/<android-app> -d Production

The above are generally the way I understand CodePush and I've tested and working fine.

Now I've noticed that we can integrate our github project branch to appcenter, and whenever there is a git push, AppCenter will build it automatically and we can configure to release to playstore automatically.

Now the part I don't understand is, is this CI auto build by AppCenter actually nothing to do with CodePush?

If now my situation is only having updates on JS code side, actually when I git-push to repo, there isn't a need to auto-release to playstore right?

Fetch request displaying response on iOS but not working with android

$
0
0

I am trying to send a response from a fetch request using React-Native for client-side and Node/Express for the server. Unfortunately, the value is only displayed with iOS emulator and not with android. I came across an article in github https://github.com/facebook/react-native/issues/24627 suggesting to add some code on the AndroidManifest file but it is still not working, I tried devices from API 25 to 29 and it worked with none. Can someone please help? Thanks for your time.

Frontend

import React, { Component } from "react";
import {Modal, StyleSheet, View, StatusBar, Text} from 'react-native'
import { Provider } from 'mobx-react';
import StateStorage from './StateStorage';


export default class App extends React.Component {

  constructor (props) {
    super(props)
    this.state ={

      data:''

    }
  }
  componentDidMount(){
    this.callBackendAPI()
    .then(res => this.setState({ data: res.express }))
    .catch(err => console.log(err));
  }
  callBackendAPI = async () => {
    const response = await fetch('http://localhost:5000');
    const body = await response.json();

    if (response.status !== 200) {
      throw Error(body.message) 
    }
    return body;
  };
  render() {
    return (
      <Provider store={StateStorage}>

<Text style={{top:100}}>{this.state.data}</Text>
        </Provider >
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',

  },

});

Backend

const express = require('express')
const app = express()
const port = process.env.PORT || 5000;

app.get('/', (req, res) => {
    res.send({ express: 'YOUR EXPRESS BACKEND IS CONNECTED TO REACT' })
}
)





app.listen(port, () => console.log(`Example app listening on port ${port}!`))

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
  package="com.mapp">

    <uses-permission android:name="android.permission.INTERNET" />

    <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"
      tools:targetApi="28"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
       <meta-data
     android:name="com.google.android.geo.API_KEY"
     android:value="AIzaSyD4Js3-PNHs1aL4XEmw6mAomblC2b4ys5s"/>
    </application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Android BiometricPrompt DeviceCredentialHandler: onCreate: Executor and/or callback was null

$
0
0

It looks like BiometricPrompt 1.0.0 has a bug where it stays in invisible state throwing that exception

ill suggest a workaround in the answer

getting variable from native module in sub class

$
0
0

I have LibModule.java set as native module in reactnative

.....

class LibModule extends ReactContextBaseJavaModule {
    boolean readingMyKad = false;

    ....


    public void read_mykad_main() {
        clear_results();
        pre_card_status = -1;
        new readMyKad(reactContext).execute();
    }


    public static class readMyKad extends AsyncTask<Void, Void, Integer> {
        CountDownTimer readMyKadCdt;
        readMyKad readMyKadObject;
        private WeakReference<ReactApplicationContext> activityReference;
        readMyKad(ReactApplicationContext reactContext) {
            activityReference = new WeakReference<>(reactContext);
        }
        protected void onPreExecute() {
            readMyKadObject = this;
            readMyKadCdt = new CountDownTimer(25000, 1000) {
                @Override
                public void onTick(long millisUntilFinished) {
                }
                @Override
                public void onFinish() {
                    if ( activityReference.get().readingMyKad ) {
                        try {
                            activityReference.get().readingMyKad = false;
                            if (readMyKadObject.getStatus() == AsyncTask.Status.RUNNING) {
                                boolean bret = readMyKadObject.cancel(true);
                                Log.e(TAG,"readMyKadAsyncTask Timeout, cancel: " + bret);
                            }
                        } catch (Exception ignored) {
                        }
                    }
                }
            };
            readMyKadCdt.start();
        }
     ...............

but in class readMyKad, i need to get variables from my main module LibModule such as activityReference.get().readingMyKad.

not just get the variable but also set and call function from LibModule. how can i do that because LibModule is not an activity.

im sorry for my english and the title.

Viewing all 28479 articles
Browse latest View live


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