android & facebook sdk - post a simple text to wall - android

What I want to do is posting a simple text to wall with the facebook sdk in android studio.
I want to post the text without the need of the Facebook app by the user.
Is that possible?
I've read
https://developers.facebook.com/docs/android/share
And I have 2 problems.
1) How can I set the text of my share?
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
.setLink("https://developers.facebook.com/android")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
I can't see any setText method..or something like that..
Also can I do this without the facebook app installed on my phone?
I get the error
Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
I don't want to force my users to have facebook installed.. what should I do ?

add permissions in manifest of your application
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SET_DEBUG_APP"/>

Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
This can happen due to the following reasons:
You are not connected to internet
You have not given permission for internet access ( Manifest.xml)
You have not used a correct hashkey for the app
You did not provide a correct App Id
You have not installed Facebook in your device
Check if you have added the permissions:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SET_DEBUG_APP"/>
EDIT:
You can use setName(String) to set the title and setDescription(String) to set the description. take a look at this documentation link.

Related

My App does not qualify for use of the requested permissions (SMS) Google new policy (Ionic 3)

We reviewed your request and found that your app, does not qualify for use of the requested permissions for the following reasons:
The declared feature {Default SMS} is allowed; however we determined it to be unnecessary for the core functionality of your app.
Default SMS [READ_SMS, SEND_SMS, WRITE_SMS, RECEIVE_SMS, RECEIVE_WAP_PUSH, RECEIVE_MMS]
I use the <uses-permission android:name="android.permission.SEND_SMS" />
to share the app via SMS (send a text and a link to the website ), whats the work arround?
Thanks
If I understand correctly you want SMS as a feature but not a requirement.
I think what you wanted to do is add uses-feature declarations with android:required="false".
From android docs
When you declare android:required="false" for a feature, it means that the application prefers to use the feature if present on the device, but that it is designed to function without the specified feature, if necessary.
Solved by removing <uses-permission android:name="android.permission.SEND_SMS" />
and calling a intent to open the Native Device Sms App

How to declare that my app can install apps from untrusted sources

In Android 0, apps that want the capability of installing apk's must be specifically granted that permission by the user in the system settings. However, I havent been able to figure out how to get my app into the list of apps the user can pick from.
Can anyone point me in the right direction?
Thanks
Probably this blog post will help:
https://android-developers.googleblog.com/2017/08/making-it-safer-to-get-apps-on-android-o.html
To sum it up:
Need to declare the permission in your manifest <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
Before install you should check if the permission is still granted (PackageManager.canRequestPackageInstalls()), if not you can request it again using
Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
intent.setData(Uri.parse("package:YOURPACKAGENAME"));

How to force permission "android.permission.CAMERA" to be added to manifest in Codename one

I am trying to show a live preview of the rear facing camera in Codename One. I use for that the native interface (I am targetting Android first).
To allow my app to use the camera without messing up with build hints, I added these lines in my Main Form :
if (Capture.hasCamera()){
Dialog.show("Appareil photo détecté", "Votre matériel est bien équipé d'un appareil photo!", "OK", null);
}
I did that because Codename One blog stated
android.hardware.camera & android.permission.RECORD_AUDIO - are triggered by com.codename1.Capture
However while debugging the app with the sources I got from CN1 under Android Studio on a real device (API LEVEL 19 aka Kit Kat) I always got a java.lang.RuntimeException: Fail to connect to camera service.
After a while I realized that the exception was due to the lack of the following permission in manifest.xml :
<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
Please note that as stated in CN1 blog the line <uses-feature android:name="android.hardware.camera" android:required="false" /> was already added by CN1.
Now that I've added this line the live preview is well shown.
Why is this permission not automatically added in the manifest, should I really add it to the build hint ?
Moreover I have another project that uses the Camera to take photo and save them on the phone and the Camera permission is neither shown (in Android Application Info) nor requested during app installation whereas it works perfectly well. Please note that e.g. Twitter App shows "Take photos and record videos" in the app permissions so it does not seem to be a problem with my phone hiding camera permission.
EDIT November 20th 2016 :
Indeed Android Developer's guide states that
Note: If you are using the camera by invoking an existing camera app, your application does not need to request this permission.
That's why CN1 does not require this permission!
Thanks for helping me getting the permission management with CN1 right.
You need to add the following build hint:
android.xpermissions=<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
You can also add this to the cn1lib so it is injected automatically.
In the past, you add the permission you want to your manifest and then it is requested when your user attempts to install your app. As of Android 6.0+, this has changed. Now you can just request a permission when your app needs it for the first time. After the user grants you permission, you don't need to ask again next time. Some benefits of this include keeping your user aware of why you need specific permissions and not requesting permissions that you don't actually need.
You can read more about how to implement it here: https://developer.android.com/training/permissions/requesting.html
There is no way to use a phones camera without asking for permission at some point.

Tasks API and OAuth 2.0 on Android sample

i'm very new to android devolopment
i tried to run the sample project given in this example
http://code.google.com/p/google-api-java-client/source/browse/tasks-android-sample/src/main/java/com/google/api/services/samples/tasks/android/TasksSample.java?repo=samples
but when i run it, it gives a force close error. after a messing around i figure that it has only list activity not activity class as others. why? how to fix it?
. my idea is to create a android software which i can push tasks from the server to the app then the app will add those as tasks in the phone? any sample apps like that?
Maybe you forgot to set the permission for Oauth?
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
New Task sample required Google Play Service Library to run you need to set up it and added into build path of your application.

Where to revoke Google API permissions granted on Android?

I'm working with some sample code here:
http://code.google.com/p/google-api-java-client/source/browse/picasa-android-sample/src/main/java/com/google/api/services/samples/picasa/android/PicasaSample.java?repo=samples
I authorized access in my Android app, but I cannot find where to now revoke access, so I can run through it again. Uninstalling the APK does not seem to reset any permissions.
I believe if you go to https://accounts.google.com/IssuedAuthSubTokens it should list your application under "Connected Sites, Apps and Services" from there you can revoke access.
Two steps to trigger the authorization page again:
go to https://accounts.google.com/IssuedAuthSubTokens to revoke the app you want. This will clear the permissions from server side.
go to your android device's settings->Data and time: fast-forward your time by a day or two. This will force the current token to expire.
It's not possible via any public, official API.
See:
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/gOVZ0DF7ccg
http://grokbase.com/t/gg/android-developers/121j6ypxkb/revoke-permissions-to-access-google-accounts
Even uninstalling and re-installing the app doesn't help.
This might be the way on a rooted device:
How do you force AccountManager to show the "Access Request" screen after a user has already allowed access?
You need to programmatically revoke the token. First, try out the example app posted at:
https://developers.google.com/drive/quickstart-android
This example app displays the dialog to let you pick an account, then takes a photo and then uploads it to Google Drive. One important thing I discovered is that this sample app will eventually fail. I discovered that the camera portion of the app causes crashes. So disable the camera part of the code and just replace the file with some file on an SD card and upload the file to Drive instead.
To revoke the permission to use Drive, you need to execute the following code:
String token = credential.getToken();
HttpRequestFactory factory = HTTP_TRANSPORT.createRequestFactory();
GoogleUrl url = new GoogleUrl("https://accounts.google.com/o/oauth2/revoke?token=" + token);
HttpRequest request = factory.buildGetRequest(url);
HttpResponse response = request.execute();
Refer to the sample code on how to access the credential variable. Also, you must run the above code in a thread that is not on the main thread or it will fail.
You also need to add the following permissions. The sample code fails to indicate these permissions and without them the app will crash:
<uses-permission android:name="android.permission.ACCOUNT_MANAGER" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
If Eclipse complains that some of those permissions are only granted to the system, just run Clean Project and it will remove the warning. After you have done this, you should uninstall the app and reboot the device. For more information about revoking tokens, see the section "Revoking a Token" at:
https://developers.google.com/accounts/docs/OAuth2WebServer
After struggling to revoke authorisation for Gmail API permissions granted on my Android app (still in debug), I worked out that it does appear on https://security.google.com/settings/security/permissions like #David Waters mentions (it's a new link but goes to the same place) but only if you've properly enabled the API via the Google Developers Console. This means properly adding your OAuth 2.0 client ID, even if the app is still in development and in Debug Mode.
There's a very good guide on how to add your credentials on the Android Quickstart guide on the Gmail API site (Steps 1 & 2).
Using Google Play Services:
http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html
Add https://www.googleapis.com/auth/userinfo.profile to your scope.
Example:
String scope="oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
final String token = GoogleAuthUtil.getToken(context, "xxxx#gmail.com", scope);
OR "brute force"
Intent res = new Intent();
res.addCategory("account:xxxx#gmail.com");
res.addCategory("scope:oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile");
res.putExtra("service", "oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile");
Bundle extra= new Bundle();
extra.putString("androidPackageName","com.your.package");
res.putExtra("callerExtras",extra);
res.putExtra("androidPackageName","com.your.package");
res.putExtra("authAccount","xxxx#gmail.com");
String mPackage = "com.google.android.gms";
String mClass = "com.google.android.gms.auth.TokenActivity";
res.setComponent(new ComponentName(mPackage,mClass));
startActivityForResult(res,100);
Now, when you revoke the access here https://accounts.google.com/IssuedAuthSubTokens the application shows you the window for permission again in the device.
You can revoke account permissons on ...
https://security.google.com/settings/security/permissions
You can get there by [Account Settings] > [Account Permissions]
Proof that this answer is the real deal:
Look into your AndroidManifest file.

Categories

Resources