According to the guide posted here I'm trying to implement my own BroadCastReceiver but in the PushManager class, there doesn't seem to be preHandlePush() and postHandlePush() defined. Am I using some outdated version of the library which I took from here? or am I missing something else?
I've update the guide (http://docs.pushwoosh.com/docs/android-faq#using-custom-push-broadcast-receiver-in-android), please take a look. These functions were moved to PushManagerImpl class.
i.e.
Bundle pushBundle = PushManagerImpl.preHandlePush(context, intent);
Related
I am a bit confused,
it seems that my Service does not print logs,
the service starts regularly (I can debug it), I see all other logs,
but from the service no logs.
Please what am I missing here?
#Override
protected void onHandleIntent(Intent intent) {
Log.e("TAG","Downlaoding devices list");//This should log something!
Chances are your IntentService is not getting called. try using the whole package name of the IntentService. I've seen this somewhere I'll post a link if I find it.
Something like this...
Intent intent = new Intent(this/*Context*/,com.myapp.MyIntentService.class);
//as opposed to
// new Intent(this, MyIntentService.class);
startService(intent);
Edit: I found the link. intentService : why my onHandleIntent is never called?
In Android Studio Logcat.
Before running your code,
1) Select No Filters instead of Show selected applications
2) In the search box, type in your tag.
3) Now Run your code and all your logs will be displayed.
Note: It won't work if you enter your tag after running your code.
My solution was selecting "No filters" in logcat spinner instead of "Show only selected application". Then you can search for TAG or whatever you know it should be shown.
In my case which is Himax M2 Y12 phone, has a peculiarity in that my TAG SensorService is blocked for unknown reason.
I changed the TAG to GeoSensorService and now the logcat is showing.
My guess is they reserve the TAG for internal purposes, but I'd argue they shouldn't use such an innocent naming (they could've prefixed reserved TAGs with __ or something).
I am trying out the Atooma SDK. They provide an abstract class IntentBasedTrigger for creating triggers that fires when the intent fires. The class has an abstract method
public String getIntentFilter() throws RemoteException
In the docs (http://www.atooma.com/developers#start/trigger) They use this with a standard Android intent. However, I want to use it with a custom Intent, so I made up a string and returned it from getIntentFilter. However, this does not work (I can't be more specific at the moment) which leads me to believe that defining intents is a bit more complicated?
IntentBasedTriggers works with custom Intent as well.
I am part of the Atooma team, unfortunally we don't have a plugin sample with IntentBasedTrigger, but you can see the SnapBack plugin using it
Here is the source code
https://github.com/SnapbackLabs/AtoomaPlugins/blob/master/AtoomaBlowDetectionPlugin/src/com/atooma/plugin/blow/TR_BlowDetectionSensorBased.java#L92
Update: Neither eclipse nor the code did cause these trouble. Genymotion did.
Maybe my approach is completely wrong, since no one else seems to have this problem - if so, i am open to try different ways rather then fix this problem:
I have the following setting.
A BroadcastReceiver is listening for installations of Apps. Whenever a new App is installed, I create a Notification, using a PendingIntent that is based on a normal Intent via
PendingIntent pIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
Before the PendingIntent is created, I put some extras in the normal Intent, that shall be passed to the Activity which is triggered, when the notification is clicked.
notificationIntent.putExtra("AppLabel", appLabel); // the installed App
notificationIntent.putStringArrayListExtra("Group", group); // the corresponding group
notificationIntent.putStringArrayListExtra("List", list); // the corresponding list
Now this works fine and the notification is displayed. Debugging I can see, that when pIntent is created, all extras are set correctly and passed.
However, when I try to read the extras in the opened Activity trouble starts. I already had to build a workaround, based on an answer here, to read the extras:
Bundle bundle = getIntent().getExtras();
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
if (key.equals("Group")) {
group = (ArrayList<String>) value;
} ... }
This also worked for a time, but now i am completely lost. For some Reason, the ArrayList extras are empty [] - the appLabel is still set correctly.
Now the real trouble is, that I am not sure if this is code related, or an eclipse issue.
I observed, that after some deployments, the bundle.keySet() returned different keys then I had set in the putExtra call. I also encounter OutOfSync errors often when I search. Refreshing does help some times, regarding the names of the keys, but the values are lost still.
To anyone who has read this: many thanks! now - has somebody a clue, what is going on here? Does anyone know similar eclipse problems? Or is there an error in the code?
Any proposals for a different design are welcome as well. I'd be just glad, if I can exclude some error sources...
Thanks in advance
Update: Manifest Infos: The launched notification Activity is defined like:
<activity
android:theme="#style/Theme.AppCompat.CompactMenu.Dialog"
android:label="Notification Receiver"
android:excludeFromRecents="true">
</activity>
The MainActivity however has just a name and a label. Besides:
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="19" />
I just added a SystemOut at two points: One when the intent is created by the BCR, one when it is read by the Activity.
BroadcastReceiver.getExtras.keyset returns [a,b,c,d]
Activity.getExtras.keyset returns the keys [x,y,z]
Searching in all Projects and all Workspace, x,y,z are nowhere to be found... They were used in a previous version of some days ago, so it seems eclipse stored some invalid old data?
Well, looks like all the technical stuff and all the outOfSync was nasty, but in the end not relevant.
It just covered a very trivial mistake. The answere can be found here:
Incorrect extras received with all intents but the first one
At least for the current implementation, this looks like solving the problems - except for the sync issues of course but that has not occured again.
My Service is only working if I have the MyService.java in a package like
com.test.app
, but NOT in a subpackage like
com.test.app.services.MyService
In the manifest I tried declaring it with
<service android:name=".services.MyService" />
or fully qualified
<service android:name="com.test.app.services.MyService" />
but neither way worked. I am using subpackages for a better structure of my files. So can I really not put my service file in a subpackage or am I missing something here?
(I am working with the Expansion Downloader Library provided by the Android team. This involves implementing a simple service.)
Yes, you can put it in whatever namespace you want.
Beyond subclassing DownloaderService you need to read the rest of the document, including Starting the download. Of particular interest is this line:
// Start the download service (if required)
int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this,
pendingIntent, SampleDownloaderService.class);
Note that you need to provide your custom Service class here.
Yes.
I've done this many times. Chances are there's something else going on. The first thing I'd check is to make sure your Intent is properly constructed.
hi
After creating intents for month now i suddenly
hit the wall when in my Notification PendingIntent, i did this:
Intent intent = new Intent(getApplicationContext(), SendFileService.class);
intent.putExtra("uuid", "123-456-34");
The SendFileService is an IntentService.
To my surprise in the IntentService onHandleIntent the extras.getString("uuid");
was null.
what can possible be the reason .
I even added an action to test but still the same.
Im clearly did something wrong or missing some knowledge about this.
Any ide?
From the docs
The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".