When user canceled the download request that requires the user confirmation, the request status is supposed to change to CANCELED. However, the state listener doesn't seem to receive that state change. Below is the example code of the listener. Any idea? Thank you in advance!
switch(state.status()) {
case SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION:
try {
getContext().startIntentSender(
state.resolutionIntent().getIntentSender(),
null,
0,
0,
0);
} catch (Exception e) {
Log.e(TAG, "stats onStateUpdate: ", e);
}
break;
case SplitInstallSessionStatus.CANCELED:
Log.d(TAG, "onStateUpdate: canceled”);
//NEVER GET TO THIS LINE
break;
}
The issue seems to be resolved in the most recent update com.google.android.play:core:1.3.7. We can't replicate the issue after the upgrade. The one we used before is 1.3.6.
Related
I have an app where i can submit a timestatus to a server.
To save battery I queue the statusitems in a SQLite Database and submit them periodically with a JobScheduler who starts an IntentService to the server.
The function to insert the items looks like this:
public synchronized void workThroughQueue() {
try {
for (QueueItem queueItem : getAllQueueItems()) {
try {
dao.insert(queueItem.getItem());
delete(queueItem);
} catch (Exception e) {
Log.e(TAG, "Queueitem konnte nicht verarbeitet werden: " + e.getMessage(), e);
}
}
} catch (Exception e) {
Log.e(TAG, "Queueverarbeitung nicht vollständig: " + e.getMessage(), e);
}
}
The service (kotlin):
class QueueService : IntentService(QueueService::class.java.name) {
override fun onHandleIntent(intent: Intent?) {
Log.d("QueueService", "Jobservice started")
TimerecordQueue().workThroughQueue()
DangerAllowanceQueue().workThroughQueue()
ProjektEndQueue().workThroughQueue()
PhotoUploadQueue().workThroughQueue()
}
}
My problem is, if the process gets killed by the system cause of low memory during dao.insert(queueItem.getItem()); it sometimes gets successfully submitted to the server but it doesn't get deleted of the queue.
So the next time the queue starts it gets submitted again.
How can i resolve this problem?
Well, in this case you can do one of the two things
In the service after insertion keep the insertion record locally(in your local database) as boolean flag as well. That will let you know for sure that your records were submitted successfully.
Second way is, when you are hitting a service, on server database before inserting record check that record is already exist. As I can see you are sending item. There should be some sort of item id. Check on server database if that record against item id exists if yes leave that record.
This should do the trick.
I have to Users (User A and B) and one Chromecast device (C1).
User B starts a stream on C1.
User A connects to C1
Now User A should be able to control the stream running on C1. But every time I want to start a session the running stream on C1 is shut down and the receiver app is restarting.
Is there a way to join an active session? Or is that a job which has to be done by the web app running on the Chromecast device?
EDIT:
my sender app is a native Android app
Thanks!
You should have a look to the TicTacToe application. I think it does exactly that where 2 players can join the same game :
https://github.com/googlecast/cast-android-tictactoe
Hope this helps.
JN
What sort of sender are you using? Is it a native app (i.e. using Android or iOs SDK on a mobile device) or the sender is a chrome app?
On the receiver, you create a Receiver object and a ChannelHandler. You use the receiver to generate a ChannelFactory which you then pass to the ChannelHandler. The ChannelHandler now handles the creation of channels on the receiver. You will want to add an EventListener to the handler to listen to messages. Based on those messages you can do various things.
receiver = new cast.receiver.Receiver(YOUR_APP_ID, [YOUR_PROTOCOL], "", 5);
var dashHandler = new cast.receiver.ChannelHandler(YOUR_PROTOCOL);
dashHandler.addChannelFactory(receiver.createChannelFactory(YOUR_PROTOCOL));
dashHandler.addEventListener(cast.receiver.Channel.EventType.MESSAGE, onMessage.bind(this));
receiver.start();
...
onMessage = function (e) {
var message = e.message;
switch (message.type) {
...
}
}
On the sender, after a session is created you will want to send a check status message to the receiver to see if there are already channels attached. You can do this via your MessageStream and your receiver needs to respond in such a way that the MessageStream gets its status updated. You check that status to see if there are channels. If there are you can start listening to updates for your receiver. If not you can send a load event to the receiver to start your activity.
MediaProtocolCommand cmd = mMessageStream.requestStatus();
cmd.setListener(new MediaProtocolCommand.Listener() {
#Override
public void onCompleted(MediaProtocolCommand mPCommand) {
if (mMessageStream.getState() == 'channelsExist') {
//Start New Activity
} else {
//Join Existing Activity
}
#Override
public void onCancelled(MediaProtocolCommand mPCommand) {
}
});
This is kind of a vague response, but it could be more specific if I knew what you were trying to do. My app is using Google's RAMP protocol to play videos so my MessageStream and all it's messages are already defined. If you're doing something different, you need to create your own MessageStream.
Sorry for the late answer, but I figured it out by myself: It wasn't such complicated at all
I started the an Application like this
try {
mSession.startSession(applicationName,applicationArgs);
} catch (IllegalStateException e) {
Log.e(getClass().getSimpleName(), e.getMessage(), e);
} catch (IOException e) {
Log.e(getClass().getSimpleName(), e.getMessage(), e);
}
But it seems, that the MimeData applicationArgs is not needed at all. By removing the arguments and starting the session like below it works really fine!
try {
mSession.startSession(applicationName);
} catch (IllegalStateException e) {
Log.e(getClass().getSimpleName(), e.getMessage(), e);
} catch (IOException e) {
Log.e(getClass().getSimpleName(), e.getMessage(), e);
}
I hope this works for you too!
I want to be able to listen (BroadcastReceiver?) for whenever a notification occurs for my app and for the calendar app, even if the user doesn't interact with it and even if the screen is off.
I also want to be able to know when a user swipes away the notification.
I know that AccessibilityEvent can enable doing the first thing (listening for notifications) but it can't do the second one (Cannot listen for notification dismissal). Is there another way?
How would I do this? Can I at least have my app/listener called when my own notifications occur (they're for calendar events) and know that the notification is still in the notification tray?
You can listen all the calendar notification info. How you say, you should use an AccessibilityService and switch the notification type. Then you get the package name an compare if it's from google calendar.
public void onAccessibilityEvent(AccessibilityEvent event) {
try {
switch (event.getEventType()) {
case AccessibilityEvent.TYPE_VIEW_CLICKED:
Log.d(LOG_SERVICE, "Click");
break;
case AccessibilityEvent.TYPE_VIEW_FOCUSED:
Log.d(LOG_SERVICE, "Focused");
break;
case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
Log.d(LOG_SERVICE, "Ihas been received a not" + type);
String pack = (String) event.getPackageName();
if (pack.equalsIgnoreCase("com.google.android.calendar")) {
//The event information.
}
break;
default:
type = "otro";
Log.d(LOG_SERVICE, "otro");
break;
}
AccessibilityNodeInfo notinfo = event.getSource();
if (notinfo != null) {
doSomethingWithNodeInfo(notinfo);
}
} catch (Exception e) {
e.printStackTrace();
}
If the Android device is with ICS or more. You can use AccessibilityNodeInfo if the app developer design their notifications with accessibility.
I am currently using Beem's source code to do developments. I would like to implement the chat state notifications. I have look through the codes and found that there is a setState() method, but I believe it has not been implemented and I have no clues about how to do it. If I use Adium to type a message to the Beem user, the Beem user is able to see that the Adium user is composing a message. But if both users are using Beem, then it does not display if the user is composing a message. Therefore, I would like to try to implement the chat state notification. How do I go about doing it? Is there any guides out there? Can someone help me? Thanks!
Add this code to setState method in ChatAdapter.java file.
org.jivesoftware.smack.packet.Message message = new org.jivesoftware.smack.packet.Message();
ChatStateExtension extension = null;
switch (state) {
case "composing":
extension = new ChatStateExtension(ChatState.composing);
break;
case "active":
extension = new ChatStateExtension(ChatState.active);
break;
case "inactive":
extension = new ChatStateExtension(ChatState.inactive);
break;
case "gone":
extension = new ChatStateExtension(ChatState.gone);
break;
case "paused":
extension = new ChatStateExtension(ChatState.paused);
break;
}
message.addExtension(extension);
try {
mAdaptee.sendMessage(message);
} catch (XMPPException e) {
e.printStackTrace();
}
I have some code that connects my app to Facebook. When you log in you proceed to the next activity. If you are already logged in when you start the app you miss out the log in section. On the following page I want to be able to log out, every time I press logout I get a null pointer. Can anyone help?
My code for log out is:
private void logout() {
try {
facebookConnector.getFacebook().logout(getApplicationContext());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
The code that is run when the app is started to check if the person has logged on is:
if (facebookConnector.getFacebook().isSessionValid()) {
Intent i = new Intent(facebook.this, facebook2.class);
startActivity(i);
finish();
}
A print screen of my error can be seen here:
Any help would be great. If you need more info please comment and I will provide asap.
facebookConnector.getFacebook() seems to return null