Google glass GDK app handling lifecycle - google-glass

I am developing an app , it has a service which renders a low frequency live card.When the app is already running, I move to OK glass and again open the app, nothing happens.I expect it to move me to left of OK glass where is live card is rendering.Is this something handled by Google glass or We should handle it explicitly?

You should handle this in your Service when it is restarted and navigate to the LiveCard with:
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (mLiveCard == null) {
mLiveCard = new LiveCard(this, LIVE_CARD_TAG);
// Initialize the LiveCard with its renderer and PendingIntent.
mLiveCard.publish(PublishMode.REVEAL);
} else {
// Navigate to the existing LiveCard.
mLiveCard.navigate();
}
return START_STICKY;
}
You can see how it's done in the Compass' CompassService class.

Related

Google Play Game Services's invite dialog doesn't show any friend

I'm trying to get GPG C++'s invitation system to work correctly for an iOS game.
I tried to call RealtimeMultiplayerManager::ShowPlayerSelectUI() to open a dialog to select friends to be invited. However, the dialog doesn't show any friend, only "Auto-Pick" option. I have several Google test accounts in the same circle, and they are already listed as testers in Google Play Console. The game is still in development.
Does anyone know what wrong?
Thanks,
Here is the code:
m_gameServices->RealTimeMultiplayer().ShowPlayerSelectUI(1, 1, true,
[this](gpg::RealTimeMultiplayerManager::PlayerSelectUIResponse const &
response){
HQRemote::Log("inviting friends %d", response.status);
if (gpg::IsError(response.status))
{
handleError((BaseStatus::StatusCode)response.status);
}
else{
auto config = gpg::RealTimeRoomConfig::Builder()
.PopulateFromPlayerSelectUIResponse(response)
.Create();
createRoom(config);
}
});
Update 21/3/2016:
Friends finally appear on the dialog's UI after 3 days of development. Why there is a delay like this?
Try to check your RealTimeMultiplayerManager::ShowPlayerSelectUI method if you misconfigured something. Here is a sample snippet.
void Engine::InviteFriend() {
service_->RealTimeMultiplayer().ShowPlayerSelectUI(
MIN_PLAYERS, MAX_PLAYERS, true,
[this](gpg::RealTimeMultiplayerManager::PlayerSelectUIResponse const &
response) {
LOGI("inviting friends %d", response.status);
// Your code to handle the users's selection goes here.
});
}
You can also look into this Adding Real-time Multiplayer Support to Your Game documentation to check your configuration.

SDL2 jbutton enum?

I'm having some trouble figuring out what enums I can/should use for SDL2's gamepad/joystick support. I tried using "SDL_CONTROLLER_*", but I ended up with some odd results. For instance:
SDL_Event e;
while (SDL_PollEvent(&e) != 0)
{
if (e.type == SDL_JOYBUTTONDOWN)
{
printf("%d\n", e.jbutton.button);
if (e.jbutton.button == SDL_CONTROLLER_BUTTON_B)
{
printf("HI\n");
}
}
}
I had this code in my function's main loop, and the second print statement goes off when I press the D-pad's DOWN button, instead of when I press the B button. I'm using an XBOX 360 controller, and it gives me no trouble at all when I play other games. Am I even using the correct enum?
A controller has different input handling than the Joystick.
You need to use Controller events:
SDL_CONTROLLERAXISMOTION: controller axis motion
SDL_CONTROLLERBUTTONDOWN: controller button pressed
SDL_CONTROLLERBUTTONUP: controller button released
SDL_CONTROLLERDEVICEADDED: controller connected
SDL_CONTROLLERDEVICEREMOVED: controller disconnected
SDL_CONTROLLERDEVICEREMAPPED: controller mapping updated
As you can see in this page https://wiki.libsdl.org/SDL_EventType.

Programmatically populated contextual "ok glass" menu

Is there any way to populate the custom "ok glass" menu in my glassware programmatically?
I have an application where the user will be in an immersion and interact with the system mainly by voice commands. The immersion consists of a CardScrollView displaying different sets of data. These sets are added and removed dynamically from a bluetooth service talking to a phone and the glass unit can't know in advance what new sets will appear.
What I want the user to be able to do is to list all current sets in the voice menu and from there choose which set to switch to. For example, if I at the moment have the sets A, B, C and D, I want the user to be able to say "ok glass, go to set", see a sub menu with A, B, C and D and then say for example "C" to switch to set C in the view.
Is this at all possible?
The glassware is going to run in a closed environment with no connection to MyGlass at all, so custom voice commands for the menu with the development permission is not a problem.
From what I understand you want you application to be already running when the user speaks. If this is correct then you can simply implement a custom menu with contextual voice commands. I believe you can always repopulate the menu just before it is being shown by overriding onPreparePanel.
I haven't tested it but guessing from the guide something like:
#Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {
if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS) {
menu.clear();
for (MyMenuItem item : mCurrentMenuItems) {
menu.add(Menu.NONE, item.getId(), Menu.NONE, item.getTitle());
}
}
return super.onPreparePanel(featureId, view, menu);
}
#Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS) {
switch (item.getItemId()) {
case MENU_ITEM_A:
// do something
break;
default:
return true;
}
return true;
}
return super.onMenuItemSelected(featureId, item);
}
MyMenuItem would be a simple class which holds a unique id of an item and its title. mCurrentMenuItems is a list of items to be shown at the moment. You can change its content using a background service, for example.

QMediaRecorder does not record anything

I have a program that records video from a web camera. It shows the camera view in the form. When start button clicked it should start recording video and should be stopped after pressing stop button. Program compiles fine but no video is recorded. Can anyone say what is the wrong with it?
Here is my code.
{
camera = new QCamera(this);
viewFinder = new QCameraViewfinder(this);
camera->setViewfinder(viewFinder);
recorder = new QMediaRecorder(camera,this);
QBoxLayout *layout = new QVBoxLayout;
layout->addWidget(viewFinder);
ui->widget->setLayout(layout);
QVideoEncoderSettings settings = recorder->videoSettings();
settings.setResolution(640,480);
settings.setQuality(QMultimedia::VeryHighQuality);
settings.setFrameRate(30.0);
//settings.setCodec("video/mp4");
recorder->setVideoSettings(settings);
recorder->setContainerFormat("mp4");
camera->setCaptureMode(QCamera::CaptureVideo);
camera->start();
}
void usbrecorder::on_btn_Record_clicked()
{
usbrecorder::startRecording();
}
void usbrecorder::on_btn_Stop_clicked()
{
usbrecorder::stopRecording();
}
void usbrecorder::startRecording()
{
recorder->setOutputLocation(QUrl::fromLocalFile("C:\\Users\\Stranger\\Downloads\\Video\\vidoe_001.mp4"));
recorder->record();
}
void usbrecorder::stopRecording()
{
recorder->stop();
}
This is due to limitations on Windows.
As mentioned in Qt documentation here: https://doc.qt.io/qt-5/qtmultimedia-windows.html#limitations
Video recording is currently not supported. Additionally, the DirectShow plugin does not support any low-level video functionality such as monitoring video frames being played or recorded using QVideoProbe or related classes.
You need to specify an output location:
QMediaRecorder::setOutputLocation(const QUrl& location)
e.g.
setOutputLocation(QUrl("file:///home/user/vid.mp4"));
Try to print the state, status and error message:
qDebug()<<record.state();
qDebug()<<record.status();
qDebug()<<record.error();
and see what it prints. With those messages you can have a clear picture of your problem. Maybe QMediaRecorder cannot access your camera.

iOS 6 Game Center Crash on Authentication

I am building a game in Cocos2d-iPhone, and while I was updating to iOS 6, I noticed that Apple changed the way Game Center authentication is done, using authenticateHandler instead of authenticateWithCompletionHandler.
I added the new authentication method, but the game now crashes if a player is not already logged in to Game Center. There is no problem authenticating if a user is already logged in.
Here is my code:
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"6.0"))
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
{
if (viewController != nil)
{
AppController *appDelegate = (AppController*)[UIApplication sharedApplication].delegate;
[delegate.viewController presentViewController:viewController animated:YES completion:nil];
}
else if (localPlayer.isAuthenticated)
{
NSLog(#"Player authenticated");
}
else
{
NSLog(#"Player authentication failed");
}
};
}
It seems like it's crashing when trying to present the Game Center viewController, even though I use the exact same code to present the GKTurnBasedMatchmakerViewController with no issues.
Any help would be much appreciated.
EDIT:
Here is the exception getting thrown on crash:
Uncaught Exception UIApplicationInvalidInterfaceOrientation: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES
Here you can find useful information about your crash, I think it is the underlying reason.
https://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html
Apps should provide the delegate method application:supportedIntefaceOrientationsForWindow and ensure that portrait is one of the returned mask values.
I added below code to fix this crash.
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
Had similar issue, I was testing the isAuthenticated and authenticateHandler from within viewDidLoad, kept crashing when trying to present the Game Center View whilst in the middle loading the current view. I moved this test into viewDidAppear
(void)viewDidAppear:(BOOL)animated{
it works fine now...
Also for ios 6, Game Center will only prompt a non authenticated user once, if they decline to sign-in, it will disable Game Center for that app, the user will then have go into Game Center to log in.