Init TelegramApplication from OsmAnd
This commit is contained in:
parent
1c2376f272
commit
20c14b5496
3 changed files with 32 additions and 0 deletions
|
@ -53,6 +53,15 @@
|
||||||
|
|
||||||
<receiver android:name=".OnTelegramServiceAlarmReceiver" />
|
<receiver android:name=".OnTelegramServiceAlarmReceiver" />
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name=".InitAppBroadcastReceiver"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="net.osmand.telegram.InitApp"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="android.support.v4.content.FileProvider"
|
android:name="android.support.v4.content.FileProvider"
|
||||||
android:authorities="net.osmand.telegram.fileprovider"
|
android:authorities="net.osmand.telegram.fileprovider"
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package net.osmand.telegram
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
|
||||||
|
class InitAppBroadcastReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
// do nothing, TelegramApplication already initialized
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package net.osmand.aidl;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -176,6 +177,7 @@ public class OsmandAidlApi {
|
||||||
registerStopNavigationReceiver(mapActivity);
|
registerStopNavigationReceiver(mapActivity);
|
||||||
registerMuteNavigationReceiver(mapActivity);
|
registerMuteNavigationReceiver(mapActivity);
|
||||||
registerUnmuteNavigationReceiver(mapActivity);
|
registerUnmuteNavigationReceiver(mapActivity);
|
||||||
|
initOsmandTelegram();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroyMapActivity(MapActivity mapActivity) {
|
public void onDestroyMapActivity(MapActivity mapActivity) {
|
||||||
|
@ -197,6 +199,15 @@ public class OsmandAidlApi {
|
||||||
return mapActivityActive;
|
return mapActivityActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initOsmandTelegram() {
|
||||||
|
String[] packages = new String[]{"net.osmand.telegram", "net.osmand.telegram.debug"};
|
||||||
|
Intent intent = new Intent("net.osmand.telegram.InitApp");
|
||||||
|
for (String pack : packages) {
|
||||||
|
intent.setComponent(new ComponentName(pack, "net.osmand.telegram.InitAppBroadcastReceiver"));
|
||||||
|
app.sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void registerRefreshMapReceiver(MapActivity mapActivity) {
|
private void registerRefreshMapReceiver(MapActivity mapActivity) {
|
||||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||||
BroadcastReceiver refreshMapReceiver = new BroadcastReceiver() {
|
BroadcastReceiver refreshMapReceiver = new BroadcastReceiver() {
|
||||||
|
|
Loading…
Reference in a new issue