+1 click is not working in Android integration with Google+ - android

I followed this link to use the +1 button in my Android application to +1 a link or a website, but unfortunately it didn't work as expected and it didn't respond when I click on it. I tried to use the following:
mPlusOneButton.setOnPlusOneClickListener(new OnPlusOneClickListener() {
#Override
public void onPlusOneClick(Intent arg0) {
// TODO Auto-generated method stub
startActivityForResult(arg0, 0);
}
});
But also no response. As an example I tried to use the following line of code:
mPlusOneButton.initialize(plusClient, "http://www.googleplustoday.net", PLUS_ONE_REQUEST_CODE);
And there is no effect on my Google plus profile at the +1 tab.
Who can help? Thanks in advance.

Make sure to be connected to Google Plus:
mPlusOneButton.setOnPlusOneClickListener(new OnPlusOneClickListener() {
#Override
public void onPlusOneClick(Intent intent) {
if(!plusClient.isConnected()) {
plusClient.connect();
} else {
startActivityForResult(intent, 0);
}
}
}

Be sure that you initialize your mPlusOneButton prior to handling clicks such as in the onResume method. When I tested by not initializing before the click then I could get it to fail.
In the androidsdk/extras/google/google_play_services/samples/plus/src/com/google/android/gms/samples/plus/PlusOneActivity.java contains a skeleton activity for getting the PlusOne button working.
If you can post your full activity code and any applicable errors from logcat that would help further identify the issue.

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();
}

Back button behavior within an InAppBrowser window with Cordova 3.6?

I'm writing a mobile application using cordova 3.6, this app just open an external url corresponding to the mobile version of my website
var ref = window.open('http://www.stackoverflow.com', '_self', 'location=no');
If a use _self as the target, the back button behavior is fine forme as it works correctly within browesed pages but the problem is that the last back in the history stack done go back on my index page and then open once again my url ! Also the events on the window doesn't work. How to exit?
var ref = window.open('http://www.stackoverflow.com', '_blank', 'location=no');
If a use _self as the target, the back button behavior is not the same. There is no back possible within browsed pages, just a back on the index page whatever we are. How can I modify the behavior to have the same as the _self?
I am stuck with these 2 solutions :(
Note: I saw this similar question but the suggested code
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialog) {
closeDialog();
}
});
no more exists in cordova InAppBrowser.java no more exist
I found a working solution for the "_blank" option target using cordova 3.6 thanks to the answer of Kris Erikson on this post
With those modifications the hardware back button works within pages in an InAppBrowser.
I copy hereafter his working solution
Go to src/com/org/apache/corodova/inappbrowser directory and edit the InAppBrowserDialog.java:
Change
public void onBackPressed () {
if (this.inAppBrowser == null) {
this.dismiss();
} else {
// better to go through the in inAppBrowser
// because it does a clean up
this.inAppBrowser.closeDialog();
}
}
to
public void onBackPressed () {
if (this.inAppBrowser == null) {
this.dismiss();
} else {
if (this.inAppBrowser.canGoBack()) {
this.inAppBrowser.goBack();
} else {
this.inAppBrowser.closeDialog();
}
}
}
Then go to InAppBrowser and find the goBack function, change:
/**
* Checks to see if it is possible to go back one page in history, then does so.
*/
private void goBack() {
if (this.inAppWebView.canGoBack()) {
this.inAppWebView.goBack();
}
}
to
/**
* Checks to see if it is possible to go back one page in history, then does so.
*/
public void goBack() {
if (this.inAppWebView.canGoBack()) {
this.inAppWebView.goBack();
}
}
public boolean canGoBack() {
return this.inAppWebView.canGoBack();
}
Please post if you find a better solution avoiding to modify the java code

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.

Facebook Android SSO weird Error

I made a previous post and I fixed the issue in that problem but I get something weirder now. So I'm following http://developers.facebook.com/docs/mobile/Android/build/#register and everything goes fine until I actually start my app. Instead of getting an app log in page, I get this:
http://imgur.com/DHpde
I have no clue why it won't go to the app log-in page like it does for everyone else. The only thing that perhaps might be different is that I had to remove the "#Override" notations for the Facebook.authorize method call.
#Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
}
#Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
#Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
#Override
public void onCancel() {
// TODO Auto-generated method stub
See this surely you will solve your error
you need to install an extension, similar to the core Android SDK, but no, here is what you need to do:
1.) go to github.com/facebook/facebook-android-sdk
2.) download the facebook directory ONLY! The other directories are only examples.
3.) Put the files from the src (you can copy the drawables too, if you want to) in the package, you are currently working with
4.) You are good to go, you can use the facebook "SDK"
see also this example https://github.com/facebook/facebook-android-sdk/tree/master/examples/Hackbook download it , it is working example provided by facebook

Does the Facebook SDK only work with Activities?

I've been trying to implement the Facebook SDK into my application in order to let users post messages on our fanwall through the app. However, I've been unsuccessful at even logging the user in through the SDK.
In the SDK examples, a simple sample has been given which uses an Activity to try and authorize the user using Single Sign-On. I've tried this example myself, and it works. I'm able to log in, I had to authorize the app to use my Facebook data and I could see the requests being made and received in LogCat.
Now, I've tried adding the same code to my own app. This app is Fragment based using the Compatibility package. There is one central FragmentActivity and the rest of my classes are simple Fragments. When adding the sample code to one of these Fragments, the Facebook app starts up for half a second when trying to authorize, but afterwards closes and nothing has happened. I'm back in my regular Fragment again.
When checking the LogCat after this, nothing suggests that the Facebook app even opened or made any requests other than the fact it shows some printing checks I added and the fact it says it's starting the Facebook intent :
01-12 13:19:40.874: I/System.out(6087): Calling authorize
01-12 13:19:40.874: I/ActivityManager(1380): Starting activity: Intent { cmp=com.facebook.katana/.ProxyAuth (has extras) } from pid 6087
01-12 13:19:40.874: I/System.out(6087): Called authorize
Other than that, nothing gets returned. No Facebook-checks, no statements saying my keys are wrong or anything, just nothing. The Facebook intent was called, but closed almost immediately and nothing else shows that it was even open.
This has been boggling my mind for a few hours now, and I'm starting to think the regular , sample-provided approach just doesn't work in Fragments due to the way Fragments work.
The code I've been using is posted below. The Fragment gets fired by a button which calls a FragmentTransaction. Am I doing something fundamentally wrong here, or does the Facebook SDK really just not work with Fragments? I've tried searching for this problem but I haven't been able to find anyone else with the same sort of situation.
public class FanWallFacebook extends Fragment {
Facebook facebook = new Facebook("294678133912628");
public FanWallFacebook() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.filler, container, false);
}
#Override
public void onStart() {
super.onStart();
System.out.println("Calling authorize");
facebook.authorize(getActivity(), new DialogListener() {
#Override
public void onComplete(Bundle values) {
System.out.println("Completed");
}
#Override
public void onFacebookError(FacebookError error) {
System.out.println("Facebook error: "+error.getMessage());
}
#Override
public void onError(DialogError e) {
System.out.println("General error: "+e.getMessage());
}
#Override
public void onCancel() {
System.out.println("Cancelled");
}
});
System.out.println("Called authorize");
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
System.out.println("Authorize callback'd");
}
}
Edit
Just tried using a FragmentActivity, and lo and behold, that does work. It successfully logs in. Seems like the SDK really only works with classes that explicitly extend ...Activity. Could anyone give me an idea why that might be the case? I always thought Fragments somewhere down the line extended Activity as well.
I ended up using a FragmentActivity for my Facebook interaction. Not the ideal solution, but it works.
well...
the new Facebook SDK has an Activity that implement FragmentActivity so problem solved.

Categories

Resources