本文整理汇总了Java中android.content.IntentFilter.MalformedMimeTypeException方法的典型用法代码示例。如果您正苦于以下问题:Java IntentFilter.MalformedMimeTypeException方法的具体用法?Java IntentFilter.MalformedMimeTypeException怎么用?Java IntentFilter.MalformedMimeTypeException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.IntentFilter
的用法示例。
在下文中一共展示了IntentFilter.MalformedMimeTypeException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enableForwarding
import android.content.IntentFilter; //导入方法依赖的package包/类
/**
* Enables forwarding of share intent between private account and managed profile.
*/
private void enableForwarding() {
Activity activity = getActivity();
if (null == activity || activity.isFinishing()) {
return;
}
DevicePolicyManager manager =
(DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
try {
IntentFilter filter = new IntentFilter(Intent.ACTION_SEND);
filter.addDataType("text/plain");
filter.addDataType("image/jpeg");
// This is how you can register an IntentFilter as allowed pattern of Intent forwarding
manager.addCrossProfileIntentFilter(BasicDeviceAdminReceiver.getComponentName(activity),
filter, FLAG_MANAGED_CAN_ACCESS_PARENT | FLAG_PARENT_CAN_ACCESS_MANAGED);
} catch (IntentFilter.MalformedMimeTypeException e) {
e.printStackTrace();
}
}
示例2: initializeNFC
import android.content.IntentFilter; //导入方法依赖的package包/类
public void initializeNFC() {
if (nfcInit == false) {
PackageManager pm = getPackageManager();
nfcSupported = pm.hasSystemFeature(PackageManager.FEATURE_NFC);
if (nfcSupported == false) {
return;
}
// when is in foreground
MLog.d(TAG, "starting NFC");
mAdapter = NfcAdapter.getDefaultAdapter(this);
// PedingIntent will be delivered to this activity
mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
// Setup an intent filter for all MIME based dispatches
IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
try {
ndef.addDataType("*/*");
} catch (IntentFilter.MalformedMimeTypeException e) {
throw new RuntimeException("fail", e);
}
mFilters = new IntentFilter[]{ ndef, };
// Setup a tech list for all NfcF tags
mTechLists = new String[][]{new String[]{NfcF.class.getName()}};
nfcInit = true;
}
}
示例3: setupForegroundDispatch
import android.content.IntentFilter; //导入方法依赖的package包/类
private static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter)
{
final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass());
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0);
IntentFilter[] filters = new IntentFilter[1];
String[][] techList = new String[][]{};
filters[0] = new IntentFilter();
filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED);
filters[0].addCategory(Intent.CATEGORY_DEFAULT);
try
{
/* Mime type for BT pairing */
filters[0].addDataType("application/vnd.bluetooth.ep.oob");
}
catch (IntentFilter.MalformedMimeTypeException e)
{
throw new RuntimeException("Unsupported mime type!");
}
/* Start Foreground dispatcher */
adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
}
示例4: endElement
import android.content.IntentFilter; //导入方法依赖的package包/类
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
super.endElement(uri, localName, qName);
switch (qName) {
case "intent-filter":
if (curActions != null) {
for (String action : curActions) {
curFilter.addAction(action);
}
}
if (curCategories != null) {
for (String cate : curCategories) {
curFilter.addCategory(cate);
}
}
if (curDataBeans != null) {
for (DataBean bean : curDataBeans) {
if (!TextUtils.isEmpty(bean.scheme)) {
curFilter.addDataScheme(bean.scheme);
}
if (!TextUtils.isEmpty(bean.host) && !TextUtils.isEmpty(bean.port)) {
curFilter.addDataAuthority(bean.host, bean.port);
}
if (!TextUtils.isEmpty(bean.path)) {
curFilter.addDataPath(bean.path, bean.getPatternMatcherType());
}
try {
if (!TextUtils.isEmpty(bean.mimeType)) {
curFilter.addDataType(bean.mimeType);
}
} catch (IntentFilter.MalformedMimeTypeException e) {
e.printStackTrace();
}
}
}
curActions = null;
curCategories = null;
curDataBeans = null;
break;
case "activity":
activities.add(curComponent);
break;
case "service":
services.add(curComponent);
break;
case "receiver":
receivers.add(curComponent);
break;
}
}