I am trying to use the Android SDK to "invite friends', however my code is giving the following error...
"failed to find provider info for
com.facebook.katana.provider.attributionid"
Could you please review my code below and help me understand what I am doing wrong.
String appLinkUrl, previewImageUrl;
appLinkUrl = "your app link url";
previewImageUrl = "https://www.example.com/my_invite_image.jpg";
if (AppInviteDialog.canShow())
{
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.setPreviewImageUrl(previewImageUrl)
.build();
AppInviteDialog appInviteDialog = new AppInviteDialog(MainActivity.this);
appInviteDialog.registerCallback(callbackManager, new FacebookCallback<AppInviteDialog.Result>()
{
#Override
public void onSuccess(AppInviteDialog.Result result)
{
}
#Override
public void onCancel()
{
}
#Override
public void onError(FacebookException e)
{
}
});
appInviteDialog.show(content);
}
Related
I think I wrote the codes correctly, but Firebase does not add data in Realtime Database. I downloaded the JSON file, connected the project, checked it via Firebase tools, but it still doesn't add data. What can I do it?
Mainactivity.java - addevent class(it will work when click the button)
private void addEvent(){
String plan = etplan.getText().toString();
String note = etnote.getText().toString();
String date = etdate.getText().toString();
String time = ettime.getText().toString();
String remb = "false";
if (remember.isChecked()==true){
remb = "true";
}
else{
remb = "false";
}
String id = dbRef.push().getKey();
Events event = new Events(id,plan,note,date,time,remb);
dbRef.child(id).setValue(event);
}
I get the following error in the Run section of the program:
glUtilsParamSize: unknow param at 0x000082
And edited this code:
dbRef.child(id).setValue(event)
.addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void unused) {
Toast.makeText(MainActivity.this,"Events Added SUCCESSFULLY!", Toast.LENGTH_SHORT).show();
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(MainActivity.this,e.toString(), Toast.LENGTH_SHORT).show();
}
});
Am trying to implement Braintree Vault PayPal payment, the problem am facing here is getting the paymentMethodNonce my event listener createdListener to capture nonce doesn't get called using vault, but everything works fine using checkout. I can't charge customer without a paymentMethodNonce, please can anyone assist me.
mBraintreeFragment = BraintreeFragment.newInstance(this,"TOKEN_FROM_SERVER");
PayPalRequest request = new PayPalRequest().localeCode("US").billingAgreementDescription("Your agreement description");
PayPal.requestBillingAgreement(mBraintreeFragment, request);
mBraintreeFragment.addListener(createdListener);
mBraintreeFragment.addListener(cancelListener);
mBraintreeFragment.addListener(errorListener);
DataCollector.collectDeviceData(mBraintreeFragment, new BraintreeResponseListener<String>() {
#Override
public void onResponse(String deviceData) {
Log.e("PayPal", deviceData);
try {
JSONObject json = new JSONObject(deviceData);
deviceDataInfo = json.getString("correlation_id");
Log.e("PayPal", deviceDataInfo);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
My Listeners
PaymentMethodNonceCreatedListener createdListener = new PaymentMethodNonceCreatedListener() {
#Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
String nonce = paymentMethodNonce.getNonce();
Log.d("PayPal", "nonce id " + nonce);
}
};
BraintreeCancelListener cancelListener = new BraintreeCancelListener() {
#Override
public void onCancel(int requestCode) {
Log.d("CreditCard", "Braintree Error Code " + requestCode);
}
};
BraintreeErrorListener errorListener = new BraintreeErrorListener() {
#Override
public void onError(Exception error) {
if (error instanceof ErrorWithResponse) {
ErrorWithResponse errorWithResponse = (ErrorWithResponse) error;
BraintreeError cardErrors = errorWithResponse.errorFor("creditCard");
if (cardErrors != null) {
List<BraintreeError> errors = cardErrors.getFieldErrors();
String err = Objects.requireNonNull(errors.get(0).getMessage());
Log.d("CreditCard", errors.toString());
}
}
}
};
Instead of adding manually your listeners to that request, it's better to just implement the interface from braintree.
For example, if you want to use the onPaymentMethodNonceCreated() just add "implements PaymentMethodNonceCreatedListener" after your class name.
public class "YourClass" implements PaymentMethodNonceCreatedListener {
//...
}
And then override the method that now the Android Studio is warning you:
#Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
String nonce = paymentMethodNonce.getNonce();
//...
}
This way you can go for everyone of your listeners! Good luck!
maybe you know is necesary add this agreement form in android
https://developers.google.com/mobile-ads-sdk/docs/dfp/android/eu-consent
i add this code just above the method onCreate on the main_activity.java
ConsentInformation consentInformation = ConsentInformation.getInstance(this);
String[] publisherIds = {"pub-123"};
ConsentInformation.getInstance(this)
.setConsentStatus(ConsentStatus.PERSONALIZED);
ConsentInformation.getInstance(this).
setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);
handler = new Handler();
consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
#Override
public void onConsentInfoUpdated(ConsentStatus consentStatus) {
// User's consent status successfully updated.
}
#Override
public void onFailedToUpdateConsentInfo(String errorDescription) {
// User's consent status failed to update.
}
});
URL privacyUrl = null;
try {
// TODO: Replace with your app's privacy policy URL.
privacyUrl = new URL("https://www.123.com/privacy");
} catch (MalformedURLException e) {
e.printStackTrace();
// Handle error.
}
ConsentForm form = new ConsentForm.Builder(this, privacyUrl)
.withListener(new ConsentFormListener() {
#Override
public void onConsentFormLoaded() {
// Consent form loaded successfully.
}
#Override
public void onConsentFormOpened() {
// Consent form was displayed.
}
#Override
public void onConsentFormClosed(
ConsentStatus consentStatus, Boolean userPrefersAdFree) {
// Consent form was closed.
}
#Override
public void onConsentFormError(String errorDescription) {
// Consent form error.
}
})
.withPersonalizedAdsOption()
.withNonPersonalizedAdsOption()
.withAdFreeOption()
.build();
form.load();
form.show();
but the form dont load when i open the app for testing. Where can be the problem. i assume, the line with: DEBUG_GEOGRAPHY_EEA << define the location of the mobile, but i dont see nothing
thanks for your time !
I am trying to make a module for react-native that will change a video into a gif. I have little to no experience with android studios/java, but I would love to learn more! I am using this library to convert the video to a gif. Here is my code:
package com.reactlibrary;
import android.widget.Toast;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.github.hiteshsondhi88.libffmpeg.FFmpeg;
public class RNGifMakerModule extends ReactContextBaseJavaModule {
private final ReactApplicationContext reactContext;
public RNGifMakerModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}
#Override
public String getName() {
return "RNGifMakerModule";
}
#ReactMethod
public void alert(String message) {
Toast.makeText(getReactApplicationContext(), "Error", Toast.LENGTH_LONG).show();
String[] cmd = {"-i"
, message
, "Image.gif"};
conversion(cmd);
}
public void conversion(String[] cmd) {
FFmpeg ffmpeg = FFmpeg.getInstance(this.reactContext);
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
#Override
public void onStart() {
}
#Override
public void onProgress(String message) {
}
#Override
public void onFailure(String message) {
}
#Override
public void onSuccess(String message) {
}
#Override
public void onFinish() {
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
e.printStackTrace();
}
}
}
And I get this error:
Error:(43, 31) error: cannot find symbol class ExecuteBinaryResponseHandler
This seems odd to be, because in the documentation for ffmpeg-android-java it says to use almost exactly the same code.
Bounty
The bounty will be awarded to you if you can find a way to convert a video.mp4 into a gif. You do not necessarily have to use FFmpeg, but your solution has to work with java/android studios.
First of all you should init ffmpeg correctly.
FFmpeg ffmpeg = FFmpeg.getInstance(this.reactContext);
// please add following method after
ffmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() {
#Override
public void onFailure() {
// probably your device not supported
}
#Override
public void onSuccess() {
// you should init flag here (isLoaded, isReady etc.)
}
Only after onSuccess() you can work with commands.
Then please check following answer by LordNeckbeard.
So your code should be something like this:
if (isFFmpegLoaded) {
// ffmpeg.execute(commands from link from the answer)
}
Please do not forget to remove all spaces from command's string and "ffmpeg" word.
To keep command more readable I will recommend to build command like this:
final String[] command = new String[11]; // example of the first command in the answer
command[0] = "-y";
command[1] = "-ss";
command[2] = "30";
command[3] = "-t";
command[4] = "3";
command[5] = "-i";
command[6] = "-t";
command[7] = "filePath";
command[8] = "-vf";
command[9] = "fps=10,scale=320:-1:flags=lanczos,palettegen";
command[10] = "palette.png";
Please make sure that you have storage permission to work with file just in case you are working on external storage.
Based on this strategy ffmpeg works well for me. Thanks and good luck!
First of all, you should use: File - Invalidate Caches/Restart - Invalidate and Restart and try to reimport ExecuteBinaryResponseHan‌dler. If the problem hasn't been resolved you can try the small hack. Inside your project create package com.github.hiteshsondhi88.libffmpeg and class:
public class ExecuteBinaryResponseHandler implements FFmpegExecuteResponseHandler {
#Override
public void onSuccess(String message) {
}
#Override
public void onProgress(String message) {
}
#Override
public void onFailure(String message) {
}
#Override
public void onStart() {
}
#Override
public void onFinish() {
}
}
It should be as on image:
Then inside your build.gradle file in defaultConfig block add multiDexEnabled true
Then you will be able to use that class
I have the following timer in onCreate():
new Timer().scheduleAtFixedRate(new TimerTask(){
public void run() {
Log.i("EOH","timer");
updateMarkers();
}}, 0, 1000);
As you can see, it calls the function updateMarkers() every second.
Here is updateMarkers():
private void updateMarkers(){
Log.i("EOH","updateMarkers()");
Drawable drawable = this.getResources().getDrawable(R.drawable.google_maps_marker);
final MyItemizedOverlay itemizedoverlay = new MyItemizedOverlay(drawable,mapView);
AsyncHttpClient myClient = new AsyncHttpClient();
final PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
myClient.setCookieStore(myCookieStore);
RequestParams params = new RequestParams();
params.put("sw_lat", String.valueOf(centrePoint.getLat()-(Double.valueOf(mapView.getLatitudeSpan())/2.0)));
params.put("sw_lng", String.valueOf(centrePoint.getLat()-(Double.valueOf(mapView.getLongitudeSpan())/2.0)));
params.put("ne_lat", String.valueOf(centrePoint.getLat()+(Double.valueOf(mapView.getLatitudeSpan())/2.0)));
params.put("ne_lng", String.valueOf(centrePoint.getLat()+(Double.valueOf(mapView.getLongitudeSpan())/2.0)));
myClient.post("http://www.prestocab.com/ajax/getRanks.php", params, new AsyncHttpResponseHandler() {
public void onStart() {
thinger.setVisibility(View.VISIBLE);
Log.i("EOH","onStart()");
}
public void onSuccess(String response) {
Log.i("EOH","xxx: "+response);
thinger.setVisibility(View.INVISIBLE);
try{
JSONArray arr=(JSONArray) new JSONTokener(response).nextValue();
Log.i("EOH","yyy: "+String.valueOf(arr.length()));
}catch(JSONException e){
}
}
public void onFailure(Throwable e) {
thinger.setVisibility(View.INVISIBLE);
}
public void onFinish() {
}
});
}
The problem I'm having is that Log.i("EOH","onStart()"); never gets called! However Log.i("EOH","updateMarkers()"); gets called...
What am I doing wrong?
Many thanks in advance,
I found out that current implementation of AsyncHttpClient - the first I start using - version 1.4.3 (2013-09-25) has some problem with local intranet hostnames. I was testing using a local network with the webserver running on my computer and it was calling onStart, but never calling onSuccess or any other methods.
My hostname was RM_UB02 (without the Internet domain suffixes). Android and Chrome web browsers were able to resolve the URL (http:// RM_UB02/test/page.html), but AsyncHttpClient never worked.
I changed to the local intranet IP address (192.168.1.104) and it started working.
I figured out that it was working all right for Internet names (http://slashdot.org ), but not for local networks.
#Override
public void onStart()
{
}
#Override
public void onFinish()
{
}
#Override
public void onSuccess()
{
}
#Override
public void onFailure()
{
}