Search in sources :

Example 91 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class BluetoothPan method doBind.

boolean doBind() {
    Intent intent = new Intent(IBluetoothPan.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0, android.os.Process.myUserHandle())) {
        Log.e(TAG, "Could not bind to Bluetooth Pan Service with " + intent);
        return false;
    }
    return true;
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 92 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class BluetoothPbapClient method doBind.

private boolean doBind() {
    Intent intent = new Intent(IBluetoothPbapClient.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0, android.os.Process.myUserHandle())) {
        Log.e(TAG, "Could not bind to Bluetooth PBAP Client Service with " + intent);
        return false;
    }
    return true;
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 93 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class BluetoothHealth method doBind.

boolean doBind() {
    Intent intent = new Intent(IBluetoothHealth.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0, android.os.Process.myUserHandle())) {
        Log.e(TAG, "Could not bind to Bluetooth Health Service with " + intent);
        return false;
    }
    return true;
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 94 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class BluetoothInputHost method doBind.

boolean doBind() {
    Intent intent = new Intent(IBluetoothInputHost.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0, android.os.Process.myUserHandle())) {
        Log.e(TAG, "Could not bind to Bluetooth HID Device Service with " + intent);
        return false;
    }
    Log.d(TAG, "Bound to HID Device Service");
    return true;
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 95 with ComponentName

use of android.content.ComponentName in project dynamic-load-apk by singwhatiwanna.

the class MainActivity method generateContentView.

private View generateContentView(final Context context) {
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    layout.setBackgroundColor(Color.parseColor("#F79AB5"));
    Button button = new Button(context);
    button.setText("Start TestActivity");
    layout.addView(button, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            DLIntent intent = new DLIntent(getPackageName(), TestFragmentActivity.class);
            // 传递Parcelable类型的数据
            intent.putExtra("person", new Person("plugin-a", 22));
            intent.putExtra("dl_extra", "from DL framework");
            startPluginActivityForResult(intent, 0);
        }
    });
    Button button2 = new Button(context);
    button2.setText("Start Service");
    layout.addView(button2, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    button2.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            DLIntent intent = new DLIntent(getPackageName(), TestService.class);
            startPluginService(intent);
        }
    });
    Button button3 = new Button(context);
    button3.setText("bind Service");
    layout.addView(button3, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    button3.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mConnecton == null) {
                mConnecton = new ServiceConnection() {

                    public void onServiceDisconnected(ComponentName name) {
                    }

                    public void onServiceConnected(ComponentName name, IBinder binder) {
                        int sum = ((ITestServiceInterface) binder).sum(5, 5);
                        Log.e("MainActivity", "onServiceConnected sum(5 + 5) = " + sum);
                    }
                };
            }
            DLIntent intent = new DLIntent(getPackageName(), TestService.class);
            bindPluginService(intent, mConnecton, Context.BIND_AUTO_CREATE);
        }
    });
    Button button4 = new Button(context);
    button4.setText("unbind Service");
    layout.addView(button4, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    button4.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            if (mConnecton != null) {
                DLIntent intent = new DLIntent(getPackageName(), TestService.class);
                unBindPluginService(intent, mConnecton);
                mConnecton = null;
            }
        }
    });
    return layout;
}
Also used : ServiceConnection(android.content.ServiceConnection) LayoutParams(android.view.ViewGroup.LayoutParams) View(android.view.View) IBinder(android.os.IBinder) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ComponentName(android.content.ComponentName) ITestServiceInterface(com.ryg.dynamicload.service.ITestServiceInterface) DLIntent(com.ryg.dynamicload.internal.DLIntent) LinearLayout(android.widget.LinearLayout)

Aggregations

ComponentName (android.content.ComponentName)2548 Intent (android.content.Intent)959 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)269 PendingIntent (android.app.PendingIntent)252 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)242 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)139 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)132 IBinder (android.os.IBinder)128 IOException (java.io.IOException)125 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)96 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)68