package com.darryncampbell.cordova.plugin.intent;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import android.text.Html;
import android.util.Log;
import android.view.KeyEvent;
import android.webkit.MimeTypeMap;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaActivity;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaResourceApi;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static android.os.Environment.getExternalStorageDirectory;
import static android.os.Environment.getExternalStorageState;
public class IntentShim extends CordovaPlugin {
private final Map<BroadcastReceiver, CallbackContext> receiverCallbacks = new HashMap<>();
private static final String LOG_TAG = "Cordova Intents Shim";
private CallbackContext onNewIntentCallbackContext = null;
private CallbackContext onActivityResultCallbackContext = null;
private Intent deferredIntent = null;
public IntentShim() {
}
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException
{
Log.d(LOG_TAG, "Action: " + action);
if (action.equals("startActivity") || action.equals("startActivityForResult"))
{
// Credit: https://github.com/chrisekelley/cordova-webintent
if (args.length() != 1) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
return false;
}
JSONObject obj = args.getJSONObject(0);
Intent intent = populateIntent(obj, callbackContext);
int requestCode = obj.has("requestCode") ? obj.getInt("requestCode") : 1;
boolean bExpectResult = false;
if (action.equals("startActivityForResult"))
{
bExpectResult = true;
this.onActivityResultCallbackContext = callbackContext;
}
startActivity(intent, bExpectResult, requestCode, callbackContext);
return true;
}
else if (action.equals("sendBroadcast"))
{
// Credit: https://github.com/chrisekelley/cordova-webintent
if (args.length() != 1) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
return false;
}
// Parse the arguments
JSONObject obj = args.getJSONObject(0);
Intent intent = populateIntent(obj, callbackContext);
sendBroadcast(intent);
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
return true;
}
else if (action.equals("startService"))
{
if (args.length() != 1) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
return false;
}
JSONObject obj = args.getJSONObject(0);
Intent intent = populateIntent(obj, callbackContext);
startService(intent);
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
return true;
}
else if (action.equals("registerBroadcastReceiver")) {
Log.d(LOG_TAG, "Plugin no longer unregisters receivers on registerBroadcastReceiver invocation");
// No error callback
if(args.length() != 1) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
return false;
}
// Expect an array of filterActions
JSONObject obj = args.getJSONObject(0);
JSONArray filterActions = obj.has("filterActions") ? obj.getJSONArray("filterActions") : null;
if (filterActions == null || filterActions.length() == 0)
{
// The arguments are not correct
Log.w(LOG_TAG, "filterActions argument is not in the expected format");
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
return false;
}
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
result.setKeepCallback(true);
IntentFilter filter = new IntentFilter();
for (int i = 0; i < filterActions.length(); i++) {
Log.d(LOG_TAG, "Registering broadcast receiver for filter: " + filterActions.getString(i));
filter.addAction(filterActions.getString(i));
}
// Allow an array of filterCategories
JSONArray filterCategories = obj.has("filterCategories") ? obj.getJSONArray("filterCategories") : null;
if (filterCategories != null) {
for (int i = 0; i < filterCategories.length(); i++) {
Log.d(LOG_TAG, "Registering broadcast receiver for category filter: " + filterCategories.getString(i));
filter.addCategory(filterCategories.getString(i));
}
}
// Add any specified Data Schemes
// https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/issues/24
JSONArray filterDataSchemes = obj.has("filterDataSchemes") ? obj.getJSONArray("filterDataSchemes") : null;
if (filterDataSchemes != null && filterDataSchemes.length() > 0)
{
for (int i = 0; i < filterDataSchemes.length(); i++)
{
Log.d(LOG_TAG, "Associating data scheme to filter: " + filterDataSchemes.getString(i));
filter.addDataScheme(filterDataSchemes.getString(i));
}
}
BroadcastReceiver broadcastReceiver = newBroadcastReceiver();
this.cordova.getActivity().registerReceiver(broadcastReceiver, filter);
receiverCallbacks.put(broadcastReceiver, callbackContext);
callbackContext.sendPluginResult(result);
}
else if (action.equals("unregisterBroadcastReceiver"))
{
try
{
unregisterAllBroadcastReceivers();
}
catch (IllegalArgumentException e) {}
}
else if (action.equals("onIntent"))
{
// Credit: https://github.com/napolitano/cordova-plugin-intent
if(args.length() != 1) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
return false;
}
this.onNewIntentCallbackContext = callbackContext;
if (this.deferredIntent != null) {
fireOnNewIntent(this.deferredIntent);
this.deferredIntent = null;
}
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
return true;
}
else if (action.equ
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
GreaterWMS仓库管理系统 v2.1.48.zip (2000个子文件)
json_value.cpp 38KB
json_reader.cpp 21KB
json_writer.cpp 20KB
plugin.cpp 7KB
tokenizer.cpp 6KB
keyboard_ndk.cpp 4KB
keyboard_js.cpp 3KB
Logger.cpp 3KB
vendor.2ac1ba6a.css 204KB
index.b358926d.css 189KB
index.b3108c34.css 189KB
index.27187eb4.css 189KB
swagger-ui.css 142KB
bootstrap.min.css 119KB
bootstrap-theme.min.css 23KB
font-awesome-4.0.3.css 21KB
base.css 20KB
responsive.css 18KB
select2.css 17KB
select2.min.css 15KB
widgets.css 11KB
autocomplete.css 9KB
forms.css 9KB
changelists.css 6KB
base.css 6KB
rtl.css 4KB
bootstrap-tweaks.css 3KB
nav_sidebar.css 3KB
notification.css 2KB
responsive_rtl.css 2KB
highlight.css 2KB
plugin-barcodeScanner.css 2KB
app.45730797.css 1KB
jquery.json-view.min.css 1KB
default.css 1KB
login.css 958B
prettify.css 817B
dark_mode.css 796B
fonts.css 423B
dashboard.css 380B
2.74c09acd.css 107B
value.h 33KB
reader.h 6KB
writer.h 6KB
json_batchallocator.h 4KB
plugin.h 2KB
tokenizer.h 2KB
config.h 2KB
CDVBattery.h 1KB
features.h 1KB
CDVNotification.h 1KB
CDVVibration.h 997B
CDVDevice.h 957B
CDVDevice.h 929B
forwards.h 735B
autolink.h 438B
IonicKeyboard.h 432B
json.h 200B
Insomnia.h 172B
keyboard_ndk.hpp 2KB
Logger.hpp 1KB
keyboard_js.hpp 1KB
说明.htm 4KB
oauth2-redirect.html 3KB
index.html 907B
index.template.html 876B
index.html 701B
index.html 616B
IntentShim.java 34KB
Notification.java 23KB
SplashScreen.java 19KB
BarcodeScanner.java 13KB
IonicKeyboard.java 6KB
BatteryListener.java 6KB
Device.java 5KB
iDataScanner.java 5KB
SeuicScanner.java 3KB
Insomnia.java 2KB
CordovaPluginIntentFileProvider.java 143B
vendor.4a49a306.js 2.15MB
swagger-ui-bundle.js 1022KB
redoc.standalone.js 1018KB
xlsx.full.min.js 930KB
IndexPage.90f6eb3b.js 569KB
IndexPage.ba58de59.js 569KB
IndexPage.b4bad113.js 569KB
IndexPage.02c4449a.js 569KB
IndexPage.838cc71a.js 569KB
IndexPage.d77216f2.js 569KB
IndexPage.542f43cc.js 569KB
IndexPage.e56673a8.js 569KB
IndexPage.e10936ec.js 569KB
IndexPage.f3bcf606.js 569KB
IndexPage.160a3dbe.js 569KB
IndexPage.c42c9800.js 569KB
IndexPage.031229a8.js 569KB
IndexPage.910ff918.js 569KB
IndexPage.1ad6b307.js 569KB
IndexPage.7ba9c6fe.js 569KB
IndexPage.bc4cad6d.js 569KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
芝麻粒儿
- 粉丝: 6w+
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功