I have an Android Wear app which was working fine on my Moto360. It access Google Play Services and GCM APIs in the Google Admin console. Then I tried to use another watch (LG G Watch). Because I can only pair one watch at any time with my phone, I had to "forget" the moto360 in order to pair with the LG G Watch. Now I cannot seem to connect to Google App API (GCM or play services). I am getting the following error:
I/GMPM ( 2746): App measurement is starting up
E/GMPM ( 2746): getGoogleAppId failed with status: 10
E/GMPM ( 2746): Uploading is not possible. App measurement disabled
This error occurs in the logcat of both the watch and the accompanying mobile app. I tried looking up what the status code but could not find any info. Could anyone please help in gleaning what this status code mean?
Replace addApi with addApiIfAvailable
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApiIfAvailable(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
I had the same problem with google's geofencing example. It was caused by location and wearable API version mismatch as you can see below.
dependencies {
compile "com.android.support:support-v4:23.0.0"
compile "com.android.support:support-v13:23.0.0"
compile "com.android.support:cardview-v7:23.0.0"
compile 'com.google.android.gms:play-services-location:7.3.0'
compile 'com.google.android.gms:play-services-wearable:7.8.0'
compile 'com.android.support:support-v13:23.0.1'
wearApp project(':Wearable')
}
Verify your build.grade to check version of API in use.
I was with same error, it was resolved with in the instantiation of Client doing:
GoogleApiClient mGoogleClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
And be sure of override this classes:
#Override
protected void onStart(){
super.onStart();
if (!mResolvingError) { // more about this later
mGoogleClient.connect();
}
}
#Override
protected void onStop(){
mGoogleClient.disconnect();
super.onStop();
}
#Override
public void onConnected(Bundle bundle) {
Log.d(TAG, "Connected");
}
#Override
public void onConnectionSuspended(int i) {
}
#Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.d(TAG, "Failed to connect");
}
I used Log.d to test the connection.
Related
Version
Microsoft.Bot.Streaming and Microsoft.Bot.Builder
"4.7.1"
Describe the bug
For direct line speech local test, set IsAuthenticationDisabledAsync to true in building a BotFrameworkHttpAdapter. SendActivityAsync() fails to send response back with below error
Failed to fetch token before processing outgoing activity. An IIdentity is required in TurnState for this operation.
For webchat test, it failed at Conversation:: ReplyToActivityWithHttpMessagesAsync, I get 401 unauthorized issue
To Reproduce
Update nuget package of BF to 4.7.1
Implement public class DisabledAuthCredentialProvider : ICredentialProvider which set IsAuthenticationDisabledAsync to true
Build BotFrameworkHttpAdapterv with DisabledAuthCredentialProvider
See exception in SendActivitiesAsync
(await this.GetAppCredentialsAsync(this.GetBotAppId(turnContext), (string) null, new CancellationToken()).ConfigureAwait(false)).GetTokenAsync(false);
Seems to work for me (in Emulator). Running 4.7.1. Here's what I have in DisabledAuthCredentialProvider
public class DisabledAuthCredentialProvider : ICredentialProvider
{
public Task<string> GetAppPasswordAsync(string appId)
{
throw new NotImplementedException();
}
public Task<bool> IsAuthenticationDisabledAsync()
{
return Task.FromResult(true);
}
public Task<bool> IsValidAppIdAsync(string appId)
{
throw new NotImplementedException();
}
}
I can share my bot if that helps.
I tried to use org.springframework.boot:spring-boot-devtools to speed up development.
My project uses Firebase to authenticate some requests. Firebase initialized via:
#PostConstruct
public void instantiateFirebase() throws IOException {
FirebaseOptions options = new FirebaseOptions.Builder()
.setDatabaseUrl(String.format("https://%s.firebaseio.com", configuration.getFirebaseDatabase()))
.setServiceAccount(serviceJson.getInputStream())
.build();
FirebaseApp.initializeApp(options);
}
After context reloading on changing .class file Spring reports error:
Caused by: java.lang.IllegalStateException: FirebaseApp name [DEFAULT] already exists!
at com.google.firebase.internal.Preconditions.checkState(Preconditions.java:173)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:180)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:160)
What Firebase API allow deregister/destroy FirebaseApp that I should use in #PreDestroy?
Looks like it is not possible to disable/shutdown/reinitialize Firebase app.
In my case it is fine to keep that instance in memory without changes.
Depending on your requirements you may use as simple as:
#PostConstruct
public void instantiateFirebase() throws IOException {
// We use only FirebaseApp.DEFAULT_APP_NAME, so check is simple.
if ( ! FirebaseApp.getApps().isEmpty())
return;
Resource serviceJson = applicationContext.getResource(String.format("classpath:firebase/%s", configuration.getFirebaseServiceJson()));
FirebaseOptions options = new FirebaseOptions.Builder()
.setDatabaseUrl(String.format("https://%s.firebaseio.com", configuration.getFirebaseDatabase()))
.setServiceAccount(serviceJson.getInputStream())
.build();
FirebaseApp.initializeApp(options);
}
or filter data like:
for (FirebaseApp app : FirebaseApp.getApps()) {
if (app.getName().equals(FirebaseApp.DEFAULT_APP_NAME))
return;
}
I have been struggling with this for several days (three actually). I have AAD B2C working on a web app and an api. I cannot get it running on my Xamarin mobile project. I am using the UWP project to test my configuration since it has the easiest app to troubleshoot on a Windows 10 machine. I am using Visual Studio 2015 Pro.
I am using the Microsoft.Identity.Client 1.1.0-preview.
I used this as my starting point for my attempt to implement.
https://github.com/Azure-Samples/active-directory-b2c-xamarin-native
Right now the project will compile and launch. When I click on Sign in, I get a WebView, but it doesn't look exactly right....
[First Image in Screenshots]
Here are my variables...
public class Constants
{
public static string ApplicationID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
public static string[] Scopes = {""};
public static string SignUpSignInPolicy = "B2C_1_Standard_SignUpSignIn";
public static string ResetPasswordPolicy = "B2C_1_Standard_PasswordReset";
public static string EditProfilePolicy = "B2C_1_Standard_EditProfile";
public static string Authority = "https://login.microsoftonline.com/[MyTennantName].onmicrosoft.com/B2C_1_Standard_SignUpSignIn";
public static string AuthorityEditProfile = "https://login.microsoftonline.com/[MyTennantName].onmicrosoft.com/B2C_1_Standard_EditProfile";
public static string ApiEndpoint = "https://[MyTennantName].onmicrosoft.com/apiservices";
public static UIParent UiParent = null;
}
My Login method is....
async void OnSignInSignOut(object sender, EventArgs e)
{
try
{
if (btnSignInSignOut.Text == "Sign in")
{
AuthenticationResult ar = await App.PCA.AcquireTokenAsync(Constants.Scopes, GetUserByPolicy(App.PCA.Users, Constants.SignUpSignInPolicy), Constants.UiParent);
UpdateUserInfo(ar);
UpdateSignInState(true);
}
else
{
foreach (var user in App.PCA.Users)
{
App.PCA.Remove(user);
}
UpdateSignInState(false);
}
}
catch (Exception ex)
{
// Checking the exception message
// should ONLY be done for B2C
// reset and not any other error.
if (ex.Message.Contains("AADB2C90118"))
OnPasswordReset();
// Alert if any exception excludig user cancelling sign-in dialog
else if (((ex as MsalException)?.ErrorCode != "authentication_canceled"))
await DisplayAlert($"Exception:", ex.ToString(), "Dismiss");
}
}
However before I can even enter my password I get the following....
[Second image in Screenshots]
My application definition looks like this...[Third image in screenshots]
I don't think it is recognizing my tenant and trying to log me in with a Microsoft account. I have double checked my Tenant name and Application ID.
Screenshots
I don't have enough reputation to post more than one link and one picture.
Also, the Azure AD B2C api application works for a web app. I have created a web app that can authenticate and works with the API.
It looks like while modifying the authorization value in the Sample you removed the /tfp/ part.
You should update your values as follows:
public static string Authority = "https://login.microsoftonline.com/tfp/[MyTennantName].onmicrosoft.com/B2C_1_Standard_SignUpSignIn";
public static string AuthorityEditProfile = "https://login.microsoftonline.com/tfp/[MyTennantName].onmicrosoft.com/B2C_1_Standard_EditProfile";
I am making a wear app which fetches data from database(which is on handheld) on launch of app home screen.
So when the homepage activity launches, It sends a message using Wearable.MessageApi.sendMessage function from the android wear to handheld. On the handheld I have the WearableListenerService which receives this message in onMessageReceived function and reads database. After reading database it sends putDatamapRequest to the wear.
Now on the wear side, I have another WearableListenerService. In this service, onDataChanged() function is never invoked. It runs at times, so far it ran for 2-3 times but otherwise it doesn't run. It's very random. Also once the data is received in Wear side, I set a static Arraylist, which I use to display data in Activity. But since the onDataChanged function is not always called, it gives empty array list.
Here is my AndroidManifest file of wear app where I declared the service:
<service
android:name="com.example.deals.DataListenerService"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
Here is my code to send message from wear to handheld:
mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
#Override
public void onConnected(Bundle bundle) {
Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
#Override
public void onResult(NodeApi.GetConnectedNodesResult getConnectedNodesResult) {
if(!getConnectedNodesResult.getNodes().isEmpty())
{
node = getConnectedNodesResult.getNodes().get(0);
System.out.println("Connected: "+ node.getId());
Wearable.MessageApi.sendMessage(mGoogleApiClient, node.getId(), FETCH_ALL_DEALS, null).setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
#Override
public void onResult(MessageApi.SendMessageResult sendMessageResult) {
if (!sendMessageResult.getStatus().isSuccess()) {
Log.e("Wear:", "ERROR: failed to send Message: " + sendMessageResult.getStatus());
}
else
System.out.println("success");
}
});
}
else
System.out.println("Wear not connected to Phone");
}
});
}
#Override
public void onConnectionSuspended(int i) {
}
})
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
#Override
public void onConnectionFailed(ConnectionResult result) {
Log.v("Phone to wear connection failed", "onConnectionFailed: " + result);
}
})
.addApi(Wearable.API)
.build();
mGoogleApiClient.connect();
Here is my code for onMessageReceive on Handheld:
public void onMessageReceived(MessageEvent messageEvent) {
System.out.println("Message Received on Phone on launch of wear homepage");
if(messageEvent.getPath().equals(FETCH_ALL_DEALS)) {
sendSavedDeals(); //fetch from db and make a datamap object using PutDataRequest
System.out.println("Message Received on Phone on launch of wear homepage");
}
else {
System.out.println("Unable to recognise action for "+messageEvent.getPath());
}
}
Now on my wear side I have a WearableListenerService but it's onDataChanged method never gets called. Could you please help me with that.
onDataChanged() is only called when the data really did change. If you put the same data into the DataApi multiple times, the method is only called once until you write different data.
To trigger an action on the wear side, even when the data didn't change, send a message after putting data into the DataApi.
Data should be changed or deleted to get call-back to onDataChanged in WearabaleListenerService in your wear.
if you want make changes open APP-info from settings and clear-data then after force stop .
Finally launch your app in phone..but ensure that wearable listener service should be already started in your wear..
When onDataChanged() is not being called :
Firstly, ensure that the handheld activity is connecting to the API at the start :
#Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
otherwise, it fails silently.
If it still doesn't work, to facilitate the debug, add this override method and this class in the handheld activity to generate data every 5 seconds :
#Override
public void onResume() {
super.onResume();
mDataItemGeneratorFuture = mGeneratorExecutor.scheduleWithFixedDelay(
new DataItemGenerator(), 1, 5, TimeUnit.SECONDS
);
}
/** Generates a DataItem based on an incrementing count. */
private class DataItemGenerator implements Runnable {
private int count = 0;
#Override
public void run() {
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(COUNT_PATH);
putDataMapRequest.getDataMap().putInt(COUNT_KEY, count++);
PutDataRequest request = putDataMapRequest.asPutDataRequest();
Log.d("yourApp", "Generating DataItem: " + request);
if (!mGoogleApiClient.isConnected()) {
return;
}
Wearable.DataApi.putDataItem(mGoogleApiClient, request)
.setResultCallback(new ResultCallback() {
#Override
public void onResult(DataItemResult dataItemResult) {
if (!dataItemResult.getStatus().isSuccess()) {
Log.e("YourApp", "ERROR: failed to putDataItem, status code: "
+ dataItemResult.getStatus().getStatusCode());
}
}
});
}
}
I use a shared Toast across different Activities in order to only show the latest message, immediately discarding any previous ones. I put the code in the custom Application object:
public class GameApp extends Application {
private Toast mToast;
#Override
public void onCreate() {
super.onCreate();
mToast = Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT);
}
public void displayToast(int textId) {
displayToast(getText(textId));
}
public void displayToast(CharSequence text) {
mToast.cancel();
mToast.setText(text);
mToast.show();
}
}
The Toast showed up on my 1.6, 2.2, and 3.0 emulators. But when I downloaded the released app from the Market, it only shows on my G1 (CyanMod 6.1) but not Xoom (3.0.1). I tried connecting the Xoom with USB debugging, but nothing relevant showed up in LogCat.
Prior to this, I used to do Toasts the conventional way (i.e. via Toast.makeText()) and that worked on everything as expected.
Could there be any potential problem with my above code, or could this be a bug in the Xoom? Here is the link to my app, in case you want to test it. The Toast should show up when you click Today, Progress in the Main screen. I appreciate any help. Thank you very much :)
i'm not sure but the sdk that motorola uses may be different.. and mToast.cancel() could be doin something terrible.. so have you tried this..
public void displayToast(CharSequence text) {
mToast.setText(text);
mToast.show();
}
This is because that mToast.cancel(); may close the toast if it's showing, or don't show it if it isn't showing yet.
Please create new Toast object when users click buttons. And keep the previous Toast object reference. Next time when user click buttons, cancel the previous Toast object and create new Toast again.
public class GameApp extends Application {
private Toast mToast;
private Context mContext;
#Override
public void onCreate() {
super.onCreate();
mToast = Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT);
}
public void displayToast(int textId,Context mContext) {
this.mContext = mContext;
displayToast(getText(textId));
}
public void displayToast(CharSequence text) {
mToast.cancel();
mToast = new Toast(mContext);
mToast.setText(text);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}