Search in sources :

Example 1 with ComponentInfo

use of android.content.pm.ComponentInfo in project VirtualApp by asLody.

the class GetIntentSender method redirectIntentSender.

private Intent redirectIntentSender(int type, String creator, Intent intent) {
    Intent newIntent = intent.cloneFilter();
    switch(type) {
        case ActivityManagerCompat.INTENT_SENDER_ACTIVITY:
            {
                ComponentInfo info = VirtualCore.get().resolveActivityInfo(intent, VUserHandle.myUserId());
                if (info != null) {
                    newIntent.setClass(getHostContext(), StubPendingActivity.class);
                    newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                }
            }
            break;
        case ActivityManagerCompat.INTENT_SENDER_SERVICE:
            {
                ComponentInfo info = VirtualCore.get().resolveServiceInfo(intent, VUserHandle.myUserId());
                if (info != null) {
                    newIntent.setClass(getHostContext(), StubPendingService.class);
                }
            }
            break;
        case ActivityManagerCompat.INTENT_SENDER_BROADCAST:
            {
                newIntent.setClass(getHostContext(), StubPendingReceiver.class);
            }
            break;
        default:
            return null;
    }
    newIntent.putExtra(StubManifest.IDENTITY_PREFIX + "_user_id_", VUserHandle.myUserId());
    newIntent.putExtra(StubManifest.IDENTITY_PREFIX + "_intent_", intent);
    newIntent.putExtra(StubManifest.IDENTITY_PREFIX + "_creator_", creator);
    newIntent.putExtra(StubManifest.IDENTITY_PREFIX + "_from_inner_", true);
    return newIntent;
}
Also used : StubPendingActivity(com.lody.virtual.client.stub.StubPendingActivity) StubPendingReceiver(com.lody.virtual.client.stub.StubPendingReceiver) StubPendingService(com.lody.virtual.client.stub.StubPendingService) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ComponentInfo(android.content.pm.ComponentInfo)

Example 2 with ComponentInfo

use of android.content.pm.ComponentInfo in project qksms by moezbhatti.

the class MainActivity method showDialogIfNeeded.

/**
 * Shows at most one dialog using the intent extras and the restored state of the activity.
 *
 * @param savedInstanceState restored state
 */
private void showDialogIfNeeded(Bundle savedInstanceState) {
    // Check if the intent has the ICON_COLOR_CHANGED action; if so, show a new dialog.
    if (getIntent().getBooleanExtra(IconColorReceiver.EXTRA_ICON_COLOR_CHANGED, false)) {
        // Clear the flag in the intent so that the dialog doesn't show up anymore
        getIntent().putExtra(IconColorReceiver.EXTRA_ICON_COLOR_CHANGED, false);
        // Display a dialog showcasing the new icon!
        ImageView imageView = new ImageView(this);
        PackageManager manager = getPackageManager();
        try {
            ComponentInfo info = manager.getActivityInfo(getComponentName(), 0);
            imageView.setImageDrawable(ContextCompat.getDrawable(getBaseContext(), info.getIconResource()));
        } catch (PackageManager.NameNotFoundException ignored) {
        }
        new QKDialog().setContext(this).setTitle(getString(R.string.icon_ready)).setMessage(R.string.icon_ready_message).setCustomView(imageView).setPositiveButton(R.string.okay, null).show();
    // Only show the MMS setup fragment if it hasn't already been dismissed
    } else if (!wasMmsSetupFragmentDismissed(savedInstanceState)) {
        beginMmsSetup();
    }
}
Also used : QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) PackageManager(android.content.pm.PackageManager) ImageView(android.widget.ImageView) ComponentInfo(android.content.pm.ComponentInfo)

Aggregations

ComponentInfo (android.content.pm.ComponentInfo)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 ImageView (android.widget.ImageView)1 StubPendingActivity (com.lody.virtual.client.stub.StubPendingActivity)1 StubPendingReceiver (com.lody.virtual.client.stub.StubPendingReceiver)1 StubPendingService (com.lody.virtual.client.stub.StubPendingService)1 QKDialog (com.moez.QKSMS.ui.dialog.QKDialog)1