Closed CjoyHome closed 6 years ago
Really you could manage whatever events ... but, if such events are external ones, you have to re-route them (take a look at #17)
This mean that you have:
window.broadcaster.addEventListener("android.intent.action.PACKAGE_ADDED", function (e) { console.log("android.intent.action.PACKAGE_ADDED received."); });
android.intent.action.PACKAGE_ADDED
and when receive event you can call
LocalBroadcastManager.getInstance(context).sendBroadcastSync(intent);
<application
android:icon = “ @drawable/ic_launcher”
android:label = “ @string/app_name” >
<receiver android:name = “MyReceiver” >
<intent-filter>
<action android:name = “android.intent.action.PACKAGE_ADDED” >
</action >
</intent-filter>
</receiver>
</application>
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
LocalBroadcastManager.getInstance(context).sendBroadcastSync(intent);
}
}
sorry, I may forgot to mention I am using Ionic 2.
this.broadcaster.addEventListener('android.intent.action.PACKAGE_ADDED').subscribe((event) =>
It is unsuccessful,
error: java.lang.RuntimeException:
Unable to instantiate receiver io.ionic.starter.CDVBroadcaster:
java.lang.ClassNotFoundException:
Didn't find class "io.ionic.starter.CDVBroadcaster"
on path: DexPathList[[zip file "/data/app/io.ionic.starter-1/base.apk"],
nativeLibraryDirectories=[/data/app/io.ionic.starter-1/lib/arm64, /system/lib64, /vendor/lib64]]
I've no idea the origin of the error. I don't know the class io.ionic.starter.CDVBroadcaster
the plugin class is org.bsc.cordova.CDVBroadcaster
I've to check, if you have anything that could help me (config.xml, snippet, ... ) please share it
您好,我使用的是ionic2 的nactive,我想问下在ionic2 中怎么样使用这个插件动态的监听安装成功的广播,我希望的是当我在app中点击下载按钮,在下载完成后自动跳转到软件安装,在这个时候注册并启用监听,当我安装完成后,给我个安装成功的返回状态,然后我在进行下一步操作,请问这个如何实现,我查了很久,由于对安卓原生不熟悉,所以没成功。谢谢
Sorry,My English is poor, now is the use of translation, I play Chinese is afraid of my expression is not clear, I am afraid that you can not understand translation.
Hello, I use is ionic2 nactive, I would like to ask how to use this plugin dynamic monitor installation successful broadcast in ionic2, I hope that when I click the download button in app, when the download completes automatically jump to the software installation, registration at this time and enable listening, when I finished the installation then, give me a return to the state of installation is successful, then I in the next step, this is how to achieve, I look for a long time, because not familiar with the original Android, so there is no success. Thank you
I'm arranging a ionic2 simple project so will be easier to understand how use this plugin
OK,thank you
May I listen to the android.intent.action.PACKAGE_ADDED now?
@CjoyHome see this link (https://stackoverflow.com/a/18829680/521197)
The steps should be:
var listener = function( e ) { console.log( "onPackagedAdded received! " + e ); } window.broadcaster.addEventListener( "onPackagedAdded", listener);
PackageAddedReceiver
in your manifest.xml
having the PACKAGE_ADDED
intent filteronReceive
method on your PackageAddedReceiver
java class and broadcasting the event to get it handled by javascript listener
final Intent intent = new Intent("onPackagedAdded"); Bundle b = new Bundle(); // put data intent.putExtras( b); LocalBroadcastManager.getInstance(this).sendBroadcastSync(intent);
@CjoyHome
As promised an ionic3 sample project using broadcaster [https://github.com/bsorrentino/ionic-broadcaster-sample]()
App into the background, can you receive the broadcast?
Should I customize the plugin in the way you do it?
I don’t know whether the app in background can receive message. This is an android matter, take a look here
If yes, I don’t think that such native event could be sent to interface during background. Probably you have to cache it and send when app back in foreground
how create a call recorder app in ionic 4
anyone please help ?
Hi @Bhanu021
Why the a call recorder app is related to this plugin?
I think that you could have more help asking on stackoverflow
Is it possible to receive the broadcast from android.intent.action.PACKAGE_ADDED?