Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
react-native-activity-android
Advanced tools
Provides a method to pause Android app (Activity.moveTaskToBack), as well as lifecycle hooks when app is paused and resumed.
Provides a method to move Android apps to the background (instead of exiting), and lifecycle hooks when the application is paused and resumed.
Useful if you want to capture listen for BackButton
press and pause your application.
Install module
npm install --save react-native-activity-android
In android/setting.gradle
...
include ':ActivityAndroid', ':app'
project(':ActivityAndroid').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-activity-android/android')
In android/app/build.gradle
...
dependencies {
...
compile project(':ActivityAndroid')
}
Register module (in MainActivity.java
)
import ca.jaysoo.activityandroid.ActivityAndroidPackage; // <---- Import here
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
......
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new ActivityAndroidPackage(this)) // <---- Add here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);
setContentView(mReactRootView);
}
......
}
Moving an application to the background.
import { BackAndroid } from 'react-native';
import ActivityAndroid 'react-native-activity-android';
BackAndroid.addEventListener('hardwareBackPress', () => {
// Note: callbacks are optional.
ActivityAndroid.moveTaskToBack(() => console.log('worked'), () => console.log('failed'));
return false; // Don't exit the app.
});
Lifecycle hooks.
import ActivityAndroid 'react-native-activity-android';
ActivityAndroid.addEventListener('activityPause', () => {
console.log('App is moved to the background');
});
ActivityAndroid.addEventListener('activityResume', () => {
console.log('App is moved to the foreground');
});
ActivityAndroid.removeEventListener('activityResume', callbackFn);
ActivityAndroid.removeEventListener('activityPause', callbackFn));
FAQs
Provides a method to pause Android app (Activity.moveTaskToBack), as well as lifecycle hooks when app is paused and resumed.
The npm package react-native-activity-android receives a total of 5 weekly downloads. As such, react-native-activity-android popularity was classified as not popular.
We found that react-native-activity-android demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.