Java Code Examples for com.facebook.react.bridge.ReactApplicationContext#getPackageName()

The following examples show how to use com.facebook.react.bridge.ReactApplicationContext#getPackageName() . 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
Source File: RNInvokeApp.java    From react-native-invoke-app with MIT License 6 votes vote down vote up
private boolean isAppOnForeground(ReactApplicationContext context) {
    /**
     * We need to check if app is in foreground otherwise the app will crash.
     * http://stackoverflow.com/questions/8489993/check-android-application-is-in-foreground-or-not
     **/
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
    if (appProcesses == null) {
        return false;
    }
    final String packageName = context.getPackageName();
    for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
        if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
                && appProcess.processName.equals(packageName)) {
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: InCallManagerModule.java    From react-native-incall-manager with ISC License 6 votes vote down vote up
public InCallManagerModule(ReactApplicationContext reactContext) {
    super(reactContext);
    mPackageName = reactContext.getPackageName();
    reactContext.addLifecycleEventListener(this);
    mWindowManager = (WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE);
    mPowerManager = (PowerManager) reactContext.getSystemService(Context.POWER_SERVICE);
    audioManager = ((AudioManager) reactContext.getSystemService(Context.AUDIO_SERVICE));
    audioUriMap = new HashMap<String, Uri>();
    audioUriMap.put("defaultRingtoneUri", defaultRingtoneUri);
    audioUriMap.put("defaultRingbackUri", defaultRingbackUri);
    audioUriMap.put("defaultBusytoneUri", defaultBusytoneUri);
    audioUriMap.put("bundleRingtoneUri", bundleRingtoneUri);
    audioUriMap.put("bundleRingbackUri", bundleRingbackUri);
    audioUriMap.put("bundleBusytoneUri", bundleBusytoneUri);
    mRequestPermissionCodePromises = new SparseArray<Promise>();
    mRequestPermissionCodeTargetPermission = new SparseArray<String>();
    mOnFocusChangeListener = new OnFocusChangeListener();
    bluetoothManager = AppRTCBluetoothManager.create(reactContext, this);
    proximityManager = InCallProximityManager.create(reactContext, this);
    wakeLockUtils = new InCallWakeLockUtils(reactContext);

    Log.d(TAG, "InCallManager initialized");
}
 
Example 3
Source File: NotificationModule.java    From things-notification with Apache License 2.0 5 votes vote down vote up
public NotificationModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.reactContext = reactContext;
    //this.reactContext.addActivityEventListener(this);
    reactContext.addActivityEventListener(this);

    thisApp = reactContext.getPackageName();
    smsApp = getDefaultSmsPackage();
    //Log.d(TAG, "sms app: "+SmsApp);
}
 
Example 4
Source File: CallNotificationManager.java    From react-native-twilio-programmable-voice with MIT License 5 votes vote down vote up
public Class getMainActivityClass(ReactApplicationContext context) {
    String packageName = context.getPackageName();
    Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
    String className = launchIntent.getComponent().getClassName();
    try {
        return Class.forName(className);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 5
Source File: MusicControlNotification.java    From react-native-music-control with MIT License 5 votes vote down vote up
public MusicControlNotification(MusicControlModule module, ReactApplicationContext context) {
    this.context = context;
    this.module = module;

    Resources r = context.getResources();
    String packageName = context.getPackageName();

    // Optional custom icon with fallback to the play icon
    smallIcon = r.getIdentifier("music_control_icon", "drawable", packageName);
    if (smallIcon == 0) smallIcon = r.getIdentifier("play", "drawable", packageName);
}
 
Example 6
Source File: RNTesseractOcrModule.java    From react-native-tesseract-ocr with MIT License 4 votes vote down vote up
public RNTesseractOcrModule(ReactApplicationContext reactContext) {
	super(reactContext);
	this.reactContext = reactContext;
	if (!this.DATA_PATH.contains(reactContext.getPackageName()))
		this.DATA_PATH += reactContext.getPackageName() + File.separator;
}
 
Example 7
Source File: MusicControlReceiver.java    From react-native-music-control with MIT License 4 votes vote down vote up
public MusicControlReceiver(MusicControlModule module, ReactApplicationContext context) {
    this.module = module;
    this.packageName = context.getPackageName();
    this.reactContext = context;
}