Published Facebook Feed can Only be Seen by Self - android

I'm using sromku to share score from my LibGDX game.
The feed was successfully published, but no one can see it but myself (even when my profile is seen by others).
Code:
public class AndroidLauncher extends AndroidApplication implements FacebookConn {
SimpleFacebook mSimpleFacebook;
OnPublishListener onPublishListener = new OnPublishListener() {
#Override
public void onComplete(String postId) {
Log.i("OnComplete", "Published successfully. The new post id = " + postId);
}
};
#Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Permission[] permissions = new Permission[] {
Permission.USER_PHOTOS,
Permission.EMAIL,
Permission.PUBLISH_ACTION,
};
SimpleFacebookConfiguration configuration =
new SimpleFacebookConfiguration.Builder()
.setAppId("410074072507300")
.setNamespace("sromkuapp")
.setPermissions(permissions)
.build();
SimpleFacebook.setConfiguration(configuration);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useImmersiveMode = true;
initialize(new Jump4Love(this), config);
}
#Override
public void onResume() {
super.onResume();
mSimpleFacebook = SimpleFacebook.getInstance(this);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mSimpleFacebook.onActivityResult(this, requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
#Override
public void submitScore(int score) {
Feed feed = new Feed.Builder()
.setMessage("message")
.setName("name")
.setCaption("caption")
.setDescription("description")
.setPicture("picture")
.setLink("link")
.build();
// Note: the values above aren't the actual values I'm using
// I only simplified them so my code becomes easier to read
mSimpleFacebook.publish(feed, true, onPublishListener);
}
}
I found a similar case in StackOverflow here.
The OP said the following:
Only without using "link" and "picture" it does appear on my friend's
News Feed
I tried removing the link and picture but the result was still the same, so my case is kinda different.
That post still has no acceptable answer btw.
======================================================================
It's useless to promote my game in Facebook if no one can see it.
I have seen posts from friends promoting other games, so I know it is possible.
Anyone has any idea why I'm having this problem?

You need to set your app “live”.
Go to Status & Review tab in app dashboard, on top you find
“Do you want to make this app and all its live features available to the general public?”
… that one you need to set to Yes.
Before setting this to Yes, your app is considered to be in “development mode”, and therefor posts made via it are not shown to users that do not have a role in your app (admin/developer/tester).

Related

Xamarin Android: using StartActivityForResult(); resultCode in OnActivityResult is always "Canceled"

I have two separate applications written using Xamarin.Android; for the sake of discussion, let's call them "Tristan" and "Isolde". Tristan has some state information that Isolde sometimes needs to know. Complication: Tristan may or may not be running at the moment Isolde develops the need to know his state.
I've got kludge working now where Isolde sends a special launch intent to Tristan, who then uses a broadcast intent to send information back to Isolde. (See my earlier question for details.)
"But wait!" I hear you cry, "Is this not a perfect use case for StartActivityForResult()?" Indeed it is! The code is a whole lot simpler, and everything I've read implies that this is how Android wants you to do stuff like this.
Unfortunately, I can't get it to work (despite trying many variations and reading the dozen-or-so related questions on this very site). My specific problem is that in Isolde's OnActivityResult() callback, the resultCode is always Result.Canceled and the data is always null.
Here is the code for Tristan (where commented-out bits represent variations I've tried):
using Android.App;
using Android.Content;
namespace com.example.Tristan.Android
{
[Activity(Name ="com.example.Tristan.Android.IsoldeQueryActivity")]
public class IsoldeQueryActivity : Activity
{
protected override void OnStart()
{
// base.OnStart();
var rtn = new Intent();
rtn.PutExtra("Test", "test");
//rtn.SetAction("TestAction");
SetResult(Result.Ok, rtn);
Finish();
//FinishActivity(1234);
}
}
}
And here is the relevant code from the Activity where Isolde needs to ask for Tristan's state:
private TaskCompletionSource<bool> TristanStateCompletion;
public async Task GetTristanState()
{
TristanStateCompletion = new TaskCompletionSource<bool>();
var req = new Intent("com.example.Tristan.Android.IsoldeQueryActivity");
//req.PutExtra(Intent.ExtraReturnResult, true);
StartActivityForResult(req, 1234);
var rtn = await TristanStateCompletion.Task;
if (!rtn) bomb("can't get state");
TristanStateCompletion = null;
}
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if(requestCode == 1234) {
DoStuffWith(data);
TristanStateCompletion?.TrySetResult(true);
}
}
Diagnostics -- or rather, a specific lack of them -- leads me to believe that Tristan's IsoldeQueryActivity.OnStart() is never actually being called.
Ideas, requests for additional information and/or useful experiments to try are all welcome. (If your idea is "Put <thing> in the manifest", remember this is Xamarin.Android and I have to do that by putting <relatedThing> in the attribute decorating the Activity.)
Edited to add: In Isolde's code, DoStuffWith(data) was crashing because data was null. When I changed that method to avoid that, I found that I got a (slightly later) exception thrown in StartActivityForResult():
Android.Content.ActivityNotFoundException No Activity found to handle Intent { act=com.example.Tristan.Android.IsoldeQueryActivity }
This leads me to believe I'm not creating the Intent properly in Isolde. Do I need to be using one of the other Intent constructors? If so, how specifically?
Okay, I think I have this figured out. The code in my original question had three major problems:
I was building the Intent incorrectly in Isolde.
I didn't export the IsoldeQueryActivity in Tristan.
The call to base.OnStart() in Tristan's OnStart override is mandatory.
Here is the working version of Tristan:
using Android.App;
using Android.Content;
namespace com.example.Tristan.Android
{
[Activity(Name ="com.example.Tristan.Android.IsoldeQueryActivity", Exported=true)]
public class IsoldeQueryActivity : Activity
{
protected override void OnStart()
{
base.OnStart();
var rtn = new Intent();
rtn.PutExtra("Test", "test");
SetResult(Result.Ok, rtn);
Finish();
}
}
}
And here is the fixed code from Isolde:
private TaskCompletionSource<bool> TristanStateCompletion;
public async Task GetTristanState()
{
TristanStateCompletion = new TaskCompletionSource<bool>();
var req = new Intent();
req.SetComponent(new ComponentName("com.example.Tristan.Android", "com.example.Tristan.Android.IsoldeQueryActivity"));
StartActivityForResult(req, 1234);
var rtn = await TristanStateCompletion.Task;
if (!rtn) bomb("can't get state");
TristanStateCompletion = null;
}
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if(requestCode == 1234) {
if(resultCode != Result.Ok) bomb("bad resultCode {0}", resultCode);
if(data == null) bomb("null data from Tristan");
DoStuffWith(data);
TristanStateCompletion?.TrySetResult(true);
}
}

Braintree Android SDK Drop-in UI not displayed

I am trying to display the Drop-in UI in my app upon clicking a specific button. I have used the guide from Braintree site but for some reason nothing is happening.
Code below:
OnClick function:
public void onClick(View v){
switch (v.getId()){
case R.id.showUI_button:
onBraintreeSubmit(v);
break;
}
}
Drop-in functions:
public void onBraintreeSubmit(View v) {
PaymentRequest paymentRequest = new PaymentRequest()
.clientToken(token)
.amount("$10.00")
.primaryDescription("Awesome payment")
.secondaryDescription("Using the Client SDK")
.submitButtonText("Pay");
startActivityForResult(paymentRequest.getIntent(this), REQUEST_CODE);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE) {
if (resultCode == BraintreePaymentActivity.RESULT_OK) {
PaymentMethodNonce paymentMethodNonce = data.getParcelableExtra(
BraintreePaymentActivity.EXTRA_PAYMENT_METHOD_NONCE
);
String nonce = paymentMethodNonce.getNonce();
// Send the nonce to your server.
}
}
}
I have checked that the token is returned from the server.
I have also tried by setting the onClick via the xml code of the button and removing the onClick from the java file but the result is the same, no UI shown.
The log has only two lines
performCreate Call Injection Manager
Timeline: Activity_idle id:android.os.BinderProxy#etc
Any ideas? If more info is needed to understand better let me know
Actually I found this there is a "BraintreeFragment" set up part. Braintree documentation needs to be more clear on this I think.
https://developers.braintreepayments.com/guides/client-sdk/setup/android/v2
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
mBraintreeFragment = BraintreeFragment.newInstance(this, mAuthorization);
// mBraintreeFragment is ready to use!
} catch (InvalidArgumentException e) {
// There was an issue with your authorization string.
}
}
The above code should work along with the previous code posted. mAuthorization is the token and needs to be valid to show the payment screen (so the variable "token" in the previous code posted which in my code I just have as private but visible from the whole activity).
Try with the test token that they have on their page and if this works then the main setup is ok.
https://developers.braintreepayments.com/start/hello-client/android/v2
For setting up tokens on your server, they have further documentation so that those test tokens work on the sandbox.

There are multiple apps registered for the AuthActivity URI scheme - Dropbox sync issue on Android

Sorry for my poor English and the fact I am a newbie on Android development.
I'm developping an Android app which should send data to the datastore of Dropbox. My problem is, when my code is getting this line:
mAccountManager.startLink(DropboxHelper.this,REQUEST_LINK_TO_DBX);
Then my logcat send me the message below:
10-19 10:40:32.411: W/com.dropbox.client2.android.AuthActivity(28381): There are multiple
apps registered for the AuthActivity URI scheme (db-qeojdcjk0dkkswc). Another app may be
trying to impersonate this app, so authentication will be disabled.
The closer explanation I have found is this one:
Android + DropboxSync startLink
But the comments have not helped me.
Here my code :
public class DropboxHelper extends ActionBarActivity {
// *** Objects and APP_KEY + APP_SECRET are instantiate here ***
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dropbox_activity);
// Set up the account manager
mAccountManager = DbxAccountManager.getInstance(getApplicationContext(), APP_KEY, APP_SECRET);
mUnlinkButton = (Button) findViewById(R.id.unlink_button);
mUnlinkButton.setVisibility(View.GONE);
// Button to link to Dropbox
mLinkButton = (Button) findViewById(R.id.link_button);
mLinkButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if ( mAccountManager.getLinkedAccount() == null )
mAccountManager.startLink(DropboxHelper.this, REQUEST_LINK_TO_DBX);
else
{
Toast.makeText(DropboxHelper.this, "Connection déjà établie, vous pouvez vous déconnecter si vous le souhaitez", Toast.LENGTH_LONG).show();
mUnlinkButton.setVisibility(View.VISIBLE);
}
}
});
mUnlinkButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
mAccountManager.unlink();
Toast.makeText(DropboxHelper.this, "Déconnecté", Toast.LENGTH_LONG).show();
}
});
// Set up the datastore manager
if (mAccountManager.hasLinkedAccount()) {
try {
// Use Dropbox datastores
mDatastoreManager = DbxDatastoreManager.forAccount(mAccountManager.getLinkedAccount());
mLinkButton.setVisibility(View.GONE);
} catch (DbxException.Unauthorized e) {
System.out.println("Account was unlinked remotely");
}
}
if (mDatastoreManager == null) {
// Account isn't linked yet, use local datastores
mDatastoreManager = DbxDatastoreManager.localManager(mAccountManager);
// Show link button
mLinkButton.setVisibility(View.VISIBLE);
}
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_LINK_TO_DBX) {
if (resultCode == Activity.RESULT_OK) {
account = mAccountManager.getLinkedAccount();
try {
// Migrate any local datastores to the linked account
mDatastoreManager.migrateToAccount(account);
// Now use Dropbox datastores
mDatastoreManager = DbxDatastoreManager.forAccount(account);
// Hide link button
mLinkButton.setVisibility(View.GONE);
} catch (DbxException e) {
e.printStackTrace();
}
} else {
// Link failed or was cancelled by the user
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
}
I can't figure out How to solve this issue, I really thank you If you can help me.
Best regards.
This generally means you have more than one app installed using the same app key. Often, this can happen if you have, for example, a sample app from the SDK as well as the app you're developing installed on the same device (or virtual device) using your app key. The solution is just to uninstall one of the apps, or use a different app key in one of them.

getAuthToken doesn't call AccountManagerCallback

My code works once the user authenticates my app to view and manage mails.
Or looks something like this:
However, for the first time (for the first request), Google's dialog shows up(above) and ask the user to authenticate, then AccountManagerCallback is never called even if the user selects 'OK' (Even 'Cancel' should return some value)
Here's my code:
AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(mAccount, "oauth2:https://mail.google.com/", null, mActivity, new OnTokenAcquired(), null);
And AccountManagerCallback code:
private class OnTokenAcquired implements AccountManagerCallback<Bundle> {
#Override
public void run(AccountManagerFuture<Bundle> result) {
// Do something useful
}
}
}
Again, my code works(AccountManagerCallback does get called) once the user selects 'OK' on the above dialog. Then call 'getAuthToken()' method again.
Above issue is found on Kitkat (Samsung Tab Pro 8.4) but not on Jelly Bean (Galaxy Nexus). Not sure if it's Kitkat vs. Jelly Bean issue or Samsung vs. Nexus issue.
If it is a bug, is there a work around?
There is a difference in KitKat. Google dialog is showed as a separate activity.
Try using something like that:
AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(mAccount, "oauth2:https://mail.google.com/", null, false, new OnTokenAcquired(), null);
Then
private class OnTokenAcquired implements AccountManagerCallback<Bundle> {
#Override
public void run(AccountManagerFuture<Bundle> result) {
// Do something useful
Bundle bundle;
bundle = result.getResult();
Intent launch = (Intent)bundle.get(AccountManager.KEY_INTENT);
if (launch != null) {
launch.setFlags(0);
mainActivity.startActivityForResult(launch, AUTHORIZATION_CODE);
}
}
}
Then
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK) {
if (requestCode == AUTHORIZATION_CODE) {
// request token here again
}
}

Androids Facebook SDK, single sign on question?

On Androids Facebook SDK there is a single login feature which I can't get to work.
Done all the key hash thing but maybe there is something wrong with this method.
What exactly should I pass on, or could somebody explain what this is supposed to do?
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
facebook.authorizeCallback(requestCode, resultCode, data);
}
Facebook Single Sign On works fine, but the documentation is not all that great. Get your class to override the Facebook DialogListener.
To request Single Sign On, make sure you're calling Facebook to authorize your app -
facebookClient = new Facebook(FB_APP_ID);
facebookClient.authorize(this,
new String[] {"publish_stream", "read_stream", "offline_access"}, this);
And you also need to override the OnComplete method. Your OnActivityResult method is absolutely fine.
I used the code given by this gentleman here, and it worked perfectly fine for me, except that some of the code that he'd written was using the old API, so you might need to change some parameters passed to methods.
I don't think single sign on could work well in the Facebook Android SDK.
In the method private boolean startSingleSignOn(Activity activity, String applicationId,String[] permissions, int activityCode){} ,you will see below
Intent intent = new Intent();
intent.setClassName("com.facebook.katana",
"com.facebook.katana.ProxyAuth");
try {
activity.startActivityForResult(intent, activityCode);
} catch (ActivityNotFoundException e) {
didSucceed = false;
}
In fact, package com.facebook.katana doesn't exist in the Facebook Android SDK.so the method private boolean startSingleSignOn(Activity activity, String applicationId,
String[] permissions, int activityCode){} will return false ,then it means that single sign-on is Not available.
facebookClient.authorize
This method doesn't work on my device until I renamed those parameters:
"com.facebook.katana","com.facebook.katana.ProxyAuth"
to
"com.facebook.katana1","com.facebook.katana.ProxyAuth1"
=(

Categories

Resources