Java Code Examples for com.facebook.react.bridge.ReactContext#getApplicationContext()

The following examples show how to use com.facebook.react.bridge.ReactContext#getApplicationContext() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
public static IntentSender getSharingSenderIntent(ReactContext reactContext) {
    synchronized (LOCK) {
        if (sTargetChosenReceiveAction == null) {
            sTargetChosenReceiveAction = reactContext.getPackageName() + "/" + TargetChosenReceiver.class.getName() + "_ACTION";
        }
        Context context = reactContext.getApplicationContext();
        if (sLastRegisteredReceiver != null) {
            context.unregisterReceiver(sLastRegisteredReceiver);
        }
        sLastRegisteredReceiver = new TargetChosenReceiver();
        context.registerReceiver(sLastRegisteredReceiver, new IntentFilter(sTargetChosenReceiveAction));
    }

    Intent intent = new Intent(sTargetChosenReceiveAction);
    intent.setPackage(reactContext.getPackageName());
    intent.putExtra(EXTRA_RECEIVER_TOKEN, sLastRegisteredReceiver.hashCode());
    final PendingIntent callback = PendingIntent.getBroadcast(reactContext, 0, intent,
            PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);

    return callback.getIntentSender();
}
 
Example 2
Source Project: react-native-share   File: RNSharePathUtil.java    License: MIT License 5 votes vote down vote up
public static void compileAuthorities(ReactContext reactContext) {
    if (authorities.size() == 0) {
        Application application = (Application) reactContext.getApplicationContext();
        if (application instanceof ShareApplication) {
            authorities.add(((ShareApplication) application).getFileProviderAuthority());
        }

        authorities.add(reactContext.getPackageName() + ".rnshare.fileprovider");
    }
}
 
Example 3
Source Project: react-native-video   File: DataSourceUtil.java    License: MIT License 4 votes vote down vote up
private static DataSource.Factory buildRawDataSourceFactory(ReactContext context) {
    return new RawResourceDataSourceFactory(context.getApplicationContext());
}