How to show a Dialog after crash by using Crashlytics? - android

How to show a Dialog after crash by using Crashlytics.
for example: after crash I need open a dialog where user will put any comment(note) how he did that crash.
Is any option in Crashlytics?

Yes, definitely. It's also extremely easy.
Crashlytics.getInstance().setListener(new CrashlyticsListener() {
#Override
public void crashlyticsDidDetectCrashDuringPreviousExecution() {
// now it's the right time to show the dialog
}
});
Crashlytics.start(context);
EDIT (Deprecated as of July 2015)
If you're using the new Fabric integration, the code is slightly different (as seen here). It should look like this:
Fabric.with(this, new Crashlytics());
Crashlytics.getInstance().setListener(new CrashlyticsListener() {
#Override
public void crashlyticsDidDetectCrashDuringPreviousExecution() {
// now it's the right time to show the dialog
}
});
EDIT 2 (The latest Fabric SDKs have deprecated the setMethods)
final CrashlyticsListener listener = new CrashlyticsListener() {
#Override
public void crashlyticsDidDetectCrashDuringPreviousExecution(){
// now it's the right time to show the dialog
}
};
final CrashlyticsCore core = new CrashlyticsCore
.Builder()
.listener(listener)
.build();
Fabric.with(this, new Crashlytics.Builder().core(core).build());
To test your integration, you can simply call Crashlytics.getInstance().crash(). Simple but handy.

Related

How add my application content with description and preview to Google search results?

I found this article: A new way to search for content in your apps and I'm really excited for this opportunity. I want to show my application content in google search results, like this:
But this article doesn't have any information about how to implement this features in your app.
I use App Indexing API in my application, as described in articles:
Add the App Indexing
API
Add URL and App Indexing
Support
This is my code:
...
private GoogleApiClient mClient;
#Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_main);
mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
public Action getAction() {
Thing object = new Thing.Builder()
.setName("Test Content")
.setDescription("Test Description")
.setUrl(Uri.parse("myapp://com.example/"))
.build();
return new Action.Builder(Action.TYPE_VIEW).setObject(object)
.setActionStatus(Action.STATUS_TYPE_COMPLETED)
.build();
}
#Override
public void onStart() {
super.onStart();
mClient.connect();
AppIndex.AppIndexApi.start(mClient, getAction());
}
#Override
public void onStop() {
AppIndex.AppIndexApi.end(mClient, getAction());
mClient.disconnect();
super.onStop();
}
...
And this is result:
Google show my application's Test Content but without description and preview image. Is there any ways to add description and preview image in Google Search Results? (like Youtube or Twitter)
Try this
Thing object = new Thing.Builder()
.setName("Test Content")
.setDescription("Test Description")
.setUrl(Uri.parse("myapp://com.example/"))
//.put("image","YourImageUrlHere")
//I took one android logo url
.put("image","http://www.logospike.com/wp-content/uploads/2015/10/Android_Logo_04.png")
.build();
That Image can be ImageObject or a Image Url.
You are using Action.VIEW_TYPE.
https://developers.google.com/android/reference/com/google/android/gms/appindexing/Action#TYPE_VIEW
As per the documentation,
public static final String TYPE_VIEW
The act of consuming static visual content.
Constant Value: "https://schema.org/ViewAction"
Refer https://schema.org/ViewAction you can find "image" object under "Properties from Thing".
Hope it will help you.

Digits android authcallback not called on success/failure otp verification

I am creating a digitsauthconfig like this:
private DigitsAuthConfig createDigitsAuthConfig() {
return new DigitsAuthConfig.Builder()
.withAuthCallBack(createAuthCallback())
.withPhoneNumber("+91")
.withThemeResId(R.style.CustomDigitsTheme)
.build();
}
Where authcallback is returned by:
private AuthCallback createAuthCallback() {
return new AuthCallback() {
#Override
public void success(DigitsSession session, String phoneNumber) {
doIfSuccessfulOtpVerification();
}
#Override
public void failure(DigitsException exception) {
doIfNotSuccessfulOtpVerification();
}
};
}
I initiate the process using a button with event listener:
digitsButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Digits.authenticate(createDigitsAuthConfig());
}
});
The problem is, once my phone number is verified, it goes back to the activity where the button is displayed and does nothing. Technically, the authcallback is never called, doesn't matter successful or not. But if I click the button again, the authcallback is called without repeating the verification step. So right now I am required to click the button twice.
What is the way around it?
Finally i got solution for that issue, May it will help you too also.
You need to remove the ActiveSession, before calling the setCallback(authCallback) like mentioned as below.It will remove the existing session(if you already entered your phone number and got an OTP) from digits. This session will will not allows you to make another session to generate an OTP. So, we have to remove it. And it will work if there is no any previous sessions.
DigitsAuthButton digitsButton = (DigitsAuthButton) findViewById(R.id.auth_button);
Digits.getSessionManager().clearActiveSession();
digitsButton.setCallback(((WyzConnectApp) getApplication()).getAuthCallback());
Digits changed the way it reference the AuthCallback passed in the Digits#authenticate call.
Now Digits holds a weak reference (to avoid a memory leak), unless you hold a strong reference, that AuthCallback will be garbage collected and the result of the flow will be never propagated.
You need to define the AuthCallback in the Application context and then use this callback in your activity and it should work.
Please check the documentation on how to do this
I know its late but may be helpful for a beginner.To verify that the session is already active, please put this code in your onCreate of that activity in which Digits phone number verification button is initialised:
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new TwitterCore(authConfig), new Digits.Builder().build());
if (Digits.getActiveSession() != null) {
Intent ss = new Intent(CurrentActivity.this, SecondActivity.class);
startActivity(ss);
finish();
}

After phone number validation from Digits by twitter, I am getting two instance of my app in recent activity

Hiii, I have looked on Digits documentation over and over for this fix but couldn't find it. Whenever I open Digit mobile validation screen and then close it, I am getting two instance of my app in recent screen.
Here is how I am setting up Digits.
On Application,
Fabric.with(this, new TwitterCore(authConfig), new Digits());
And at activity,
DigitsAuthButton digitsButton = (DigitsAuthButton) findViewById(R.id.btn_phone_auth);
digitsButton.setAuthTheme(R.style.CustomDigitsTheme);
AuthCallback authCallback = new AuthCallback() {
#Override
public void success(DigitsSession session, String phoneNumber) {
//validated number processing
};
digitsButton.setCallback(authCallback);
Need help on this.
This issue is been resolved in Digits v1.10.0.
compile('com.digits.sdk.android:digits:1.10.0#aar') {
transitive = true;
}

Incorporating Simple-Facebook but get error

I am trying to use Simple-Facebook. Everything looks great and i have no errors....until i run it....
Then i get this error
Add reference from Simple Facebook project to FacebookSDK project.
It says that something is wrong here
#Override
public void onCreate() {
super.onCreate();
APP_ID = getString(R.string.facebook_app_id);
// set log to true
//Logger.DEBUG_WITH_STACKTRACE = true;
// initialize facebook configuration
Permission[] permissions = new Permission[] {
Permission.PUBLIC_PROFILE,
Permission.PUBLISH_ACTION,
Permission.PUBLIC_PROFILE
};
SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
.setAppId(APP_ID)
.setNamespace(APP_NAMESPACE)
.setPermissions(permissions)
// .setDefaultAudience()
.setAskForAllPermissionsAtOnce(false)
.build();
SimpleFacebook.setConfiguration(configuration);
// Utils.printHashKey(this);
}
}
I have absolutely no idea what to do...I saw somewhere that it does this if you dont have the FaceBook SDK imported.... but i believe i do. I am able to access all of the facebook buttons like "LoginButton" and so on... PLEASE HELP

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