The Pebble Docs clearly describe how to start a watchapp on the Pebble from an Android app, but I cannot find instructions on how to start an Android app from a watchapp. Is that possible, and how?
It's possible by registering a broadcast receiver for the pebble events, here's the code:
<receiver android:exported="true" android:name=".MyBroadcastReceiver">
<intent-filter>
<action android:name="com.getpebble.action.app.RECEIVE"/>
<action android:name="com.getpebble.action.app.RECEIVE_ACK"/>
<action android:name="com.getpebble.action.app.RECEIVE_NACK"/>
</intent-filter>
</receiver>
Related
I just enabled Notification Access permission to my app. But the Notification Listener starts Only I restart the device.How can I enable the service once my app gets installed?
You have to register a receiver in your AndroidManifest.xml.
Like below (This is an example of the GCM listener for Google Cloud Messaging)
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
</intent-filter>
</receiver>
Let me know if you need more info. But I assume you know how this works since you seem to have implemented the
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
Can you share you AndroidManifest.xml?
I have a Install referrer receiver in my manifest.
<receiver
android:name="xx.yy.zz.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
And I get the referrer in the broadcast receiver as:
String referrer = intent.getStringExtra("referrer");
My doubt is would the receiver also listen to broadcasts of other apps which are installed with a referrer.
I want to listen to broadcasts for my app only.
If this problem exists, what would be the solution for it?
<receiver
android:name="xx.yy.zz.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
**<data android:scheme="package" />**
</intent-filter>
</receiver>
add your package in the receiver and while receive the broadcast in the OnReceive method check for your package
this will solve your problem
I recently did a code scan on my Android source code using HPFortify service. They reported security vulnerability regarding google analytics receiver. They suggested to use the broadcaster permission to reduce the attack vector. This way you are restricting broadcaster, otherwise any malicious application can send the intent and broadcast receiver will process it.
Here is my AndroidManifest file.
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>
I am trying to figure out the broadcaster permission for AnalyticsReceiver. According to HpFortify the broadcast receiver should look like similar to this:
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:permission="SOME-GOOGLE-ANALYTICS-PERMISSION"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>
</intent-filter>
</receiver>
Edit 1:
I am also looking for the source code to figure out the right permission. But I couldn't find the google analytics source code.
I have a broadcastReceiver registered in manifest that receives broadcasts sent from one of my services with a custom action. I have it already working but for security reasons i want to prevent other apps from sending fake broadcast to my receiver. How can i do that?
Manifest
<receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="MyAction"/>
</intent-filter>
</receiver>
Every reciever with exported tag set to false will only receive broadcasts sent from its own application process.
so it will be:
<receiver android:name=".MyReceiver"
android:exported="false">
<intent-filter>
<action android:name="MyAction"/>
</intent-filter>
</receiver>
As another solution i found that i can use permissions.
more on here
I am new to android. I am using a Broadcast receiver which listens when a app is installed or removed.. When a app is installed or removed my Broadcast Receivers's onReceive(context,intent) will be called.. Now i need to get the info about the application installed or removed (Mainly the package name)..
Plz help
You can try this receiver and permission. (But this seem only work in /system/app)^^"
<receiver
android:name="com.your.receiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />
All the information you want is in the Intent extras.
Look at How to find the package name which has been uninstalled when using Intent.ACTION_PACKAGE_REMOVED