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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations