Can not get Registration ID in Emulator - android

Hi I am running ADMMessenger sample application provided with SDK.
in which I am not able to get Registration ID in register() method of MainActivity.
Method is like this.
private void register()
{
final ADM adm = new ADM(this);
if (adm.isSupported())
{
if(adm.getRegistrationId() == null)
{
adm.startRegister();
} else {
// final MyServerMsgHandler srv = new MyServerMsgHandler();
// srv.registerAppInstance(getApplicationContext(), adm.getRegistrationId());
}
Log.v("log_tag","Reg_id:: "+adm.getRegistrationId());
}
}
in Log cat I am always getting Reg_id:: null
and onRegistrationError() method of SampleADMMessageHandler is calling.
and error at there is ERROR_SERVICE_NOT_AVAILABLE
I can not understand what is problem, please help me.

For the service to work correctly you need to be using the Kindle image (not a generic Android one) and also make sure you have logged into your account on the device (pull down the status bar at the top and ensure you have selected an account)

Related

How to know if a given device is in the list of supported devices for ARCore?

I am using Google CoreAR package in my React-Native app for AR support. There are some devices which support AR and some not. I am getting error while I run the application in non-supported devices. I want to render a message instead showing error on the screen. For this Google CoreAR package is providing the solution which is not working for me.
void maybeEnableArButton() {
ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(this);
if (availability.isTransient()) {
// Continue to query availability at 5Hz while compatibility is checked in the background.
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
maybeEnableArButton();
}
}, 200);
}
if (availability.isSupported()) {
mArButton.setVisibility(View.VISIBLE);
mArButton.setEnabled(true);
} else { // The device is unsupported or unknown.
mArButton.setVisibility(View.INVISIBLE);
mArButton.setEnabled(false);
}
}
The problem with above code snippet is that availability.isSupported() is always returning true and that's why else part of code is not running. Can you guys please help me with this?
Thank you.
I found solution for this problem. ArCoreApk.Availability has some methods which can be used. You can find these methods in the
documentation. The method ArCoreApk.Availability
return either SUPPORTED_INSTALLED or SUPPORTED_NOT_INSTALLED depending on device support. So based on this return value we can do the stuff.
I did like this.
#ReactMethod
public ArCoreApk.Availability getSupport(){
ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(this.getReactApplicationContext());
return availability.name();
}

What the App is it that package name is android?

I have a list of package name that executed my app.
and the list is like this.
android (?)
com.gau.go.launcherex
android (?)
I confused I never seen this package name (android).
anyone has idea? thx for help.
here is the code to make list of package name
Uri ref = getReferrer();
if (ref != null) {
String host = ref.getHost();
if (host != null && !host.equals("")) {
boolean isWhite = false;
for (String item : whitelist) {
if (item.equals(host)) {
isWhite = true;
break;
}
}
if (!isWhite) {
// add to list
}
}
}
which package you've never seen? can you post more complete log and code which logged these lines? com.gau.go.launcherex is available HERE in Google Play, this is device launcher (what is launcher in HERE). and simple android package may mean app is bring-back from background using some system option, e.g. recents button/menu
edit due code posted in question - some suggestions: instead of for loop just use whiteList.contains(host), if you need to null/empty check host String then use TextUtils.isEmpty

Android TurnBasedMutliplayer No Callbacks

I have been following the guide here to add TurnBased Multiplayer to an android game. https://developers.google.com/games/services/android/turnbasedMultiplayer#before_you_begin. I have coded everything up and am able to have users login to google play services. Then using the BaseGameUtils I attempt to create a match using the following function below but I never receive a callback other than timeouts.
void CreateMatch(MatchConfig matchConfig) {
int minAutoMatchPlayers = 2;
int maxAutoMatchPlayers = 2;
Bundle autoMatchCriteria = TurnBasedMatchConfig.createAutoMatchCriteria(minAutoMatchPlayers, maxAutoMatchPlayers, 0);
TurnBasedMatchConfig curMatch = TurnBasedMatchConfig.builder()
.setAutoMatchCriteria(autoMatchCriteria)
.build();
if (!googleApiClient.isConnected()) {
Log.d(TAG, "Not connected to google api so unable to create a match");
return;
}
// Attempt creating a match and set this as the callback
Games.TurnBasedMultiplayer.createMatch(googleApiClient, curMatch).setResultCallback(this, 5, TimeUnit.SECONDS);
}
I implemented the ResultCallback<TurnBasedMultiplayer.InitiateMatchResult> in the same class, but as mentioned never get any callbacks.
public void onResult(TurnBasedMultiplayer.InitiateMatchResult initiateMatchResult) {
Status status = initiateMatchResult.getStatus();
Log.d(TAG, "Match creation status " + status);
Im not sure how to debug this further or why im not getting any callbacks. I have:
Setup my developer account and added/enable turnbased games. The App is in Alpha there.
Setup the OAuth key and AppId in the manifest.
Tested with signed APKs. Tested with two different google accounts on
two different phones.
Tried using Games.TurnBasedMultiplayer.loadMatchesByStatus(googleApiClient,
TurnBasedMatch.MATCH_TURN_STATUS_ALL).setResultCallback(this); but
it always returns 0 matches.
Any information on how to debug this
further would be greatly appreciated.
Did you try adding
Implement OnInvitationReceivedListener and OnTurnBasedMatchUpdateReceivedListener
to your activity?
Also
In onConnected(Bundle connectionHint) Games.Invitations.registerInvitationListener(mGoogleApiClient, this) and Games.TurnBasedMultiplayer.registerMatchUpdateListener(mGoogleApiClient, this)

where to initialize the ID from GCM?

I use GCM in my project.Where do I get an ID, so it is always available at all times? Here is my code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (!CloudMessaging.checkPlayServices(this)) {
return;
}
CloudMessaging.getInstance(this).setRegistrationListener(eventHandler);
}
"but if I turn aside and then expand Programmes at, then again will get ID." ->Possibly:
If I change my orientation, then again I get a new Id.
You can get your ID for GCM
if (m_gcm == null)
{
m_gcm = GoogleCloudMessaging.getInstance(m_context);
}
m_regid = m_gcm.register("Your project id from google api console");
Note : please do this network operation in background thread..
Use SharedPreferences to store your ID once you get a new one.
Steps required: (do this in your onCreate)
Check if you already have a valid GCM id in your SharedPreferences
If you already have one, use it.
Otherwise, request a new one and save it in your SharedPreferences.

android usage of "controller.query(activity);" in scoreloop

i am attempting to implement a built in controller that is part of the scoreloop library. the documentation states:
Basic Usage:
To invoke the TOS dialog if it was not accepted previously, the following code may be used:
final TermsOfServiceController controller = new TermsOfServiceController(new TermsOfServiceControllerObserver() {
#Override
public void termsOfServiceControllerDidFinish(final TermsOfServiceController controller, final Boolean accepted) {
if(accepted != null) {
// we have conclusive result.
if(accepted) {
// user did accept
}
else {
// user did reject
}
}
}
});
controller.query(activity);
but when i paste this into my code i get the following syntax errors:
am i using this incorrectly? how and where would this be used any ideas?
EDIT: after moving the statement to the method where i want to show the dialog i now get the following error:
You seem to be calling controller.query(activity) in a class body where a declaration is expected. Move the statement controller.query(activity) to a method where you would like to show the dialog.

Categories

Resources