Android 获取隐含意图的动作和类别
我需要从第三方库中获取隐含的意图。它不起作用,所以我想验证我使用的操作和类别是否正确。我想LogCat可能会显示这个,但事实似乎并非如此Android 获取隐含意图的动作和类别,android,android-intent,Android,Android Intent,我需要从第三方库中获取隐含的意图。它不起作用,所以我想验证我使用的操作和类别是否正确。我想LogCat可能会显示这个,但事实似乎并非如此 那么,如何显示隐含意图的动作和类别?要在活动类中捕捉隐含意图,请使用 Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) &&
那么,如何显示隐含意图的动作和类别?要在活动类中捕捉隐含意图,请使用
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
handleSendText(intent); // Handle text being sent
} else if (type.startsWith("image/")) {
handleSendImage(intent); // Handle single image being sent
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
if (type.startsWith("image/")) {
handleSendMultipleImages(intent); // Handle multiple images being sent
}
} else {
// Handle other intents, such as being started from the home screen
}
如果您想进一步了解,请参阅此链接: