IllegalStateException when sharing timelineitem on glass - google-mirror-api

I'm developing my firsrt glassware. Everything works fine but sharing timeline item causes glass to crash. When I select share option from actions, Glass asks me to select contacts. When I choose the contact, it shows Sharing progress then shows Shared message and about a second later, Glass stops unexpectedly and Glass Home starts again. I won't get notification to my callback url and timeline item duplicated in my timeline with only delete action available. I checked the logs of Glass and get the following exception:
09-16 18:45:57.986 18588-18638/? W/dalvikvm: threadid=28: thread exiting with uncaught exception (group=0x40db11f8)
09-16 18:45:57.994 18588-18638/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #12
java.lang.IllegalStateException: Expected condition to be true.
at com.google.glass.predicates.Assert.assertTrue(Assert.java:82)
at com.google.glass.share.ShareTimelineItemJob$4.onExecute(ShareTimelineItemJob.java:305)
at com.google.glass.timeline.TimelineHelper$Update.execute(TimelineHelper.java:279)
at com.google.glass.timeline.TimelineHelper.atomicUpdateTimelineItem(TimelineHelper.java:638)
at com.google.glass.share.ShareTimelineItemJob.updateToFinalShareItem(ShareTimelineItemJob.java:349)
at com.google.glass.share.ShareTimelineItemJob.run(ShareTimelineItemJob.java:154)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
09-16 18:45:58.033 189-3487/? W/ActivityManager: Force finishing activity com.google.glass.home/.timeline.MainTimelineActivity
09-16 18:45:58.088 18588-18588/? I/ShareActivity: onPause: 428d7a80
09-16 18:45:58.119 697-1145/? W/VoiceEngine: Stopping reading from microphone because read < 0
09-16 18:45:58.119 697-1145/? W/VoiceEngine: Stopped reading from microphone
09-16 18:45:58.135 189-494/? I/ActivityManager: START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.google.glass.home/.timeline.MainTimelineActivity} from pid 0
I'm using Java example project. And this is the code that I inserted the timeline item
TimelineItem timelineItem = new TimelineItem();
List<MenuItem> menuItemList = new ArrayList<MenuItem>();
menuItemList.add(new MenuItem().setAction("SHARE"));
timelineItem.setMenuItems(menuItemList);
timelineItem.setText("Hello Glass");
// Triggers an audible tone when the timeline item is received
timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));
MirrorClient.insertTimelineItem(credential, timelineItem);
What am I doing wrong?
UPDATE:
I tried following request from playground and it causes the exception as well
{
"kind": "mirror#timelineItem",
"id": "1100196a-10b1-4ce4-9639-6e75b5a8c881",
"created": "2013-09-17T09:25:29.818Z",
"updated": "2013-09-17T09:25:29.818Z",
"etag": "\"hzfI85yu0lKQdtWV4PO1jAbQxWw/Tth-2CVHTjXcdWQ64xW2tMt--sk\"",
"text": "This item auto-resizes according to the text length",
"menuItems": [
{
"action": "SHARE"
}
],
"notification": {
"level": "DEFAULT"
}
}

This was a bug in XE9. It was reported in issue #197 on the official issue tracker.
Per the release notes it was fixed in XE10.

Related

UIActivityViewController showing "Unable to Load" row in iOS 11

I was using a UIActivityViewController instance in several previous versions of an app in order to share content through AirDrop, and other services. And now, without even recompiling, when running the app in iOS 11 Beta, the dialog (UIActivityViewController instance) shows the following row with the message "Unable to load":
Here is the code:
let handlerOk = { () -> Void in
let activityItems = [NSURL(fileURLWithPath: fullPath, isDirectory: true)]
self.viewControllerShare = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
if let viewControllerShare = self.viewControllerShare {
viewControllerShare.popoverPresentationController?.sourceView = sender
let excludedActivities = [
UIActivityType.postToFacebook,
UIActivityType.postToTwitter,
UIActivityType.postToWeibo,
//UIActivityType.message,
//UIActivityType.mail,
UIActivityType.print,
UIActivityType.copyToPasteboard,
UIActivityType.assignToContact,
UIActivityType.saveToCameraRoll,
UIActivityType.addToReadingList,
UIActivityType.postToFlickr,
UIActivityType.postToVimeo,
UIActivityType.postToTencentWeibo,
UIActivityType.openInIBooks
]
viewControllerShare.excludedActivityTypes = excludedActivities
self.present(viewControllerShare, animated: true, completion: nil)
}
}
Right now I'm compiling with XCode 9 in Swift 4, but I don't think this is relevant since as said, if an older version of the app is run in iOS 11 (compiled with XCode 8.somenthing or even downloading the binary from TestFlight) the problem is the same. So this really looks like an iOS 11 API problem...
Is there anything new regarding the dialog initialization that may prevent the "Unable to load" row to appear?
EDIT: I tested a third party app (from Apple) that uses the same sharing dialog, and found that that row belongs to iCloud. But I'm not using iCloud in my app, so the previous UIActivityViewController behaviour was correct: it just did not show anything. So I made an experiment: disabled from iOS' Settings the iCloud permission for that third party app, and it showed the same unkind "Unable to load" message. I hope this is not the way that the final iOS 11 version works, and that it's just a Beta problem.
That said, workarounds are still welcome! Thanks!

Media has stopped working the way it should

I have an app which I made over two years ago which has a list of videos. When one of the list buttons is clicked, the media played full screen. This was working perfectly OK on Android (I have't tried other platforms) until I resubmitted it to the build server on 31-07-2016. After this I noticed that the videos were no longer working full screen.
This month, I resubmitted the app to the build server and now there are a couple of things that don't work. The most noticeable feature is that the video is stretched in portrait mode to fill the form (even without setFullScreen()). The other issue I have noticed is that if I click the back button and play another video, I get the new video and the old video still playing at the side / corner of the screen. I have tried pause() and cleanup() but they seem to have no effect. I have tried adding the Media directly to a Container and using MediaPlayer and found the same issues with both.
try {
((com.codename1.ui.layouts.BorderLayout) getLayout()).setCenterBehavior(com.codename1.ui.layouts.BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
Media media = createMedia(currentExternalContent.getIs(), "video/m4v");
Component videoComponent = media.getVideoComponent();
Container videoContainer = new Container(new com.codename1.ui.layouts.BorderLayout());
videoContainer.addComponent(BorderLayout.CENTER, videoComponent);
addComponent(BorderLayout.CENTER, videoContainer);
revalidate();
media.play();
} catch (IOException ex) {
// Dialog.show("Catch", ex.getMessage(), "OK", "Cancel"); // gives 'read failed: EBADF (Bad file descriptor)'
}
}

UIActivityViewController.completionWithItemsHandler is not called on iOS 10.0 when I select "Print" menu and cancel it

I created a simple application which uses UIActivityViewController as below.
let text = "Test Text"
let printData = UISimpleTextPrintFormatter(text: text)
let vc = UIActivityViewController(activityItems: [text, printData], applicationActivities: nil)
vc.completionWithItemsHandler = { (type,completed,items,error) in
print("completed. type=\(type) completed=\(completed) items=\(items) error=\(error)")
}
vc.modalPresentationStyle = .popover
vc.popoverPresentationController?.sourceView = self.openActivityButton
vc.popoverPresentationController?.sourceRect = self.openActivityButton.bounds
vc.popoverPresentationController?.permittedArrowDirections = .up
vc.popoverPresentationController?.delegate = self
self.present(vc, animated: true) { () in
}
and I run this application on iOS 10 (Xcode 8.0 beta 6).
When I close activity dialog, the completionWithItemsHandler is called.
When I select "Copy" activity, the completionWithItemsHandler is called.
When I select "Mail" activity and cancel it, the completionWithItemsHandler is called.
But, when I select "Print" activity and cancel it, the completionWithItemsHandler is not called.
This strange behavior occurred on iOS 10 but not occurred on iOS9 (the handler was called on iOS9)
Is this iOS 10's bug? If so, are there any workarounds to detect the UIActivityController is dismissed?
I pushed this sample app on https://github.com/kunichiko/ios10-activity-bug
I had a similar problem. In my case, I noticed that the completion handler was not called because the UIActivityController was already dismissed and deallocated. What I did was just add a property to hold a strong reference and set it to nil later. Then the completion handler was called properly.

SISSDB - writing custom message

I am using SSIS 2012 - project deployment model, utilizing the out of the box SSISDB logging.
However, I was wondering how to log custom messages to the SSISDB, i.e. "hello world" when the package start or when a certain event is raised. Is this possible?
Or do I have to fallback to a custom log table, which seems to defeat the advantage of the SSISDB logging.
Thanks!
Of course it is. What message would you like to log? http://msdn.microsoft.com/en-us/library/ms136054.aspx
This is an example from a Script Task (Control Flow)
bool fireAgain = false;
Dts.Events.FireInformation(0, "Test", "I am the description", string.Empty, 0, ref fireAgain);
This is an example from a Script Component (Data Flow)
bool fireAgain = false;
ComponentMetaData.FireInformation(0, "Test too", "I am data flow description", string.Empty, 0, ref fireAgain);
You can then look in your reports or write custom queries against catalog.operation_messages in SSISDB. When we were loading our data warehouse, if I found employee ids that the data didn't support, I'd fire off OnInformation events with the words Research in the title and then parse out the bits I needed (employee id and the date).

Windows Phone 7 Push Notifications Not Showing Up On My Phone

UPDATE: The plot thickens. I changed my channel name and it is suddenly working (which means it wasn't a problem with my push service, since I'm getting the same HTTP response from the Microsoft Push Notification server).
To me, however, this is not a solution. How will I be able to test this and KNOW my users are getting their push notifications if I'm getting the same response when it's not working as I do when it is?
[ORIGINAL POST]
I've been trying to get push notifications sent to my Windows Phone 7 device, but I'm having very big problems that I can't find any answers for. I'll start with the c# code.
I set up push notifications using the following C# code.
private HttpNotificationChannel channel;
private static string PUSH_CHANNEL = "MySpecialPushChannel";
private Uri PushUri = null;
private bool IsPushRegistered = false;
public void StartPushSubscription()
{
try
{
channel = HttpNotificationChannel.Find(PUSH_CHANNEL);
}
catch
{}
if (channel != null)
{
PushUri = channel.ChannelUri;
if (!channel.IsShellTileBound)
channel.BindToShellTile();
}
else
{
channel = new HttpNotificationChannel(PUSH_CHANNEL);
channel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(channel_ChannelUriUpdated);
channel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(channel_HttpNotificationReceived);
channel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(channel_ErrorOccurred);
try
{
channel.Open();
channel.BindToShellTile();
}
catch (Exception err)
{
channel = null;
IsPushRegistered = false;
// Code to try again
}
}
}
void channel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
{
PushUri = e.ChannelUri;
IsPushRegistered = true;
}
I'm following the standard WP7 push structure:
Find the HttpNotificationChannel (or start a new one)
Register event handler to get the push notification uri back
Open the channel
Bind to the tile
Handle the channel Uri (which we send to our service to await the happy day when we send the push notification
OK... so far so good. No errors, I get my Uri, send it to my service just fine. I pin my app to the start screen and my service sends a push request to the Uri (sending just the count so that I get a little push count number in the upper right hand corner). I get back an HTTP 200 status with the following:
DeviceConnectionStatus => Connected
NotificationStatus => Received
SubscriptionStatus => Active
And then... nothing. No push status shows up on my app. I've now tried it on my device, in the emulator, on another device, and with multiple servers and the result is always the same. Everything looks like it is working except for the fact that it doesn't work.
To me, however, this is not a solution. How will I be able to test this and KNOW my users are getting their push notifications if I'm getting the same response when it's not working as I do when it is?
The answer is, you can't. It's a limitation of how WP7 handles notifications.
For structured notifications like Tile and Toast, if you get the Connected/Active/Received/200 response, then you can know that MPNS accepted your notification request. However, this does not mean that you have sent a valid XML payload.
The component that handles parsing XML is the Push Client, the process running on the phone that accepts push notifications and deals them out to appropriate applications, displays the toast, etc.
If you have sent invalid XML, there is absolutely no indication that you've done so. At most, if you try to send the notification again to that same push channel URI, you'll get a 404 in response. Apparently getting an invalid XML payload for a specific application makes that application's push channel close, requiring you to go through the whole procedure again.
I've discovered this while debugging with our server team, and through trying to get the phone to display an alternate live tile. The only advice I can offer you is to quadruple-check your XML.
You will get errors in your error event handler for your push notification channel for Toast notifications that have invalid XML, since you are able to send/receive toast notifications while the application is active.
If anyone from Microsoft is reading this, PLEASE provide more thorough documentation on possible error states in the push notification system. We also need an event handler for Tile notifications, or at least allow us to receive tile notifications while the app is in the foreground and fire the notification channel error event so that we can be aware that our XML payload is invalid.
Especially if your web service isn't built with WCF, .NET, Azure, and whatever, working with Push Notifications on WP7 is like wandering blind.
Documentation for an exception message reading "InvalidOperationException(Failed to open channel)" should not read: "This exception is raised when the notification channel failed to open. Try opening the notification channel again." (reference)
are you getting the URL from each device? you need to get a URL from the push notification sevice for each device everytime your device connects,
when it does you need to find a way of retrieving the url from each client,
once you do that and your still not receiving push notifications then I would write to microsoft to see if they can see anything to do with the push notifications

Resources