kra*_*off 29 android phonegap-plugins cordova
我编写了一个CordavaPlugin派生类.
public class ShowMap extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args,
CallbackContext callbackContext) throws JSONException {
if (action.compareTo("showMap") == 0)
{
String message = args.getString(0);
this.echo(message, callbackContext);
Intent i = new Intent();
return true;
}
return false;
}
private void echo(String message, CallbackContext callbackContext) {
if (message != null && message.length() > 0) {
callbackContext.success(message);
} else {
callbackContext.error("Expected one non-empty string argument.");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想从这堂课开一个新的活动.如何访问基于phonegap的课程的原始上下文?
ρяσ*_*я K 42
试着:
Context context=this.cordova.getActivity().getApplicationContext();
//or Context context=cordova.getActivity().getApplicationContext();
Intent intent=new Intent(context,Next_Activity.class);
context.startActivity(intent);
//or cordova.getActivity().startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
并确保您已注册下一个活动 AndroidManifest.xml
小智 16
请享用
if (action.equals("myaction")) {
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Context context = cordova.getActivity()
.getApplicationContext();
Intent intent = new Intent(context, MyNewActivityGap.class);
cordova.getActivity().startActivity(intent);
}
});
return true;
}
Run Code Online (Sandbox Code Playgroud)Context context = cordova.getActivity().getApplicationContext();
Intent intent = new Intent(context,Next_Activity.class);
cordova.startActivityForResult(this, intent,0);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
36092 次 |
| 最近记录: |