mirror of
https://github.com/lampaa/com.lampa.startapp.git
synced 2026-02-15 00:07:54 +08:00
update plugin and readme
This commit is contained in:
@@ -4,9 +4,9 @@ cordova-plugin-startapp
|
||||
Phonegap 3.0.0 plugin for launch other application in android device.
|
||||
|
||||
|
||||
Install: ```cordova plugin add https://github.com/lampaa/startApp.git```
|
||||
Install: ```cordova plugin add https://github.com/lampaa/org.apache.cordova.startapp.git```
|
||||
|
||||
Delete: ```cordova plugin rm org.apache.cordova.core.startapp```
|
||||
Delete: ```cordova plugin rm org.apache.cordova.startapp```
|
||||
|
||||
use:
|
||||
```js
|
||||
|
||||
@@ -52,7 +52,6 @@ public class startApp extends CordovaPlugin {
|
||||
*/
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
if (action.equals("startapp")) {
|
||||
this.beep(1);
|
||||
this.startApp(args.getString(0));
|
||||
}
|
||||
else {
|
||||
@@ -70,30 +69,8 @@ public class startApp extends CordovaPlugin {
|
||||
|
||||
|
||||
/**
|
||||
* Beep plays the default notification ringtone.
|
||||
*
|
||||
* @param count Number of times to play notification
|
||||
* startApp
|
||||
*/
|
||||
public void beep(long count) {
|
||||
Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
||||
Ringtone notification = RingtoneManager.getRingtone(this.cordova.getActivity().getBaseContext(), ringtone);
|
||||
|
||||
// If phone is not set to silent mode
|
||||
if (notification != null) {
|
||||
for (long i = 0; i < count; ++i) {
|
||||
notification.play();
|
||||
long timeout = 5000;
|
||||
while (notification.isPlaying() && (timeout > 0)) {
|
||||
timeout = timeout - 100;
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startApp(String component) {
|
||||
Intent LaunchIntent = this.cordova.getActivity().getPackageManager().getLaunchIntentForPackage(component);
|
||||
this.cordova.getActivity().startActivity(LaunchIntent);
|
||||
|
||||
Reference in New Issue
Block a user