i use Google Analytics for monitor my users in my Android app. Now i want to set label's for each activity in google analytics. Just for better understanding i don't want see Activity Class name, instead see my custom label's. how i can do this?
in onCreate:
// Get tracker.
Tracker t = ((MyApplicationClass)
getActivity().getApplication()).getTracker(MyApplicationClass.TrackerName.APP_TRACKER);
// Set screen name. Where path is a String representing the screen name.
t.setScreenName("YOUR_CUSTOM_LABLE_FOR_THIS_SCREEN");
// Send a screen view.
t.send(new HitBuilders.AppViewBuilder().build());
Initialize variable:
private Tracker tracker;
onCreate()
tracker = ((GlobalClass) getApplication()).getTracker(GlobalClass.TrackerName.APP_TRACKER);
tracker.setScreenName("Add_your_own_lable");
tracker.send(new HitBuilders.AppViewBuilder().build());
Hope this will help you.
You can also configure the activity names with XML tracker configuration file.
https://developers.google.com/analytics/devguides/collection/android/v4/#analytics-xml
For example if you like to name "com.example.app.MainActivity" activity as "Home Screen" you can add:
<screenName name="com.example.app.MainActivity">
Home Screen
</screenName>
to the configuration file. When creating the tracker, make sure you are using the XML configuration instead of hardcoded trackerId.
Related
I need to Implement the dialoges given in Image to introduce attributes of App, I couldn't find the way to implement it yet.
I have tried Firebase InAppMessaging but it's automatically being displayed just after the App starts. What I need is the Message dialog should display after a button gets clicked.
the code I putted in the button.OnclickListener
FirebaseInAppMessaging.getInstance().triggerEvent("CompaignId");
Link to Firebase InAppMessaging Docs from where I get the given code
You can use BubbleShowCase to achieve your dialog.
How to use it in the simplest way:
BubbleShowCaseBuilder(this) //Activity instance
.title("foo") //Any title for the bubble view
.targetView(view) //View to point out
.show() //Display the ShowCase
And if you will read more in the library page you can find info about making a custom dialog.
You can use full-screen dialog with transparent background and show whatever feature you have to show
e.g
Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog_layout);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
dialog.show()
There's a lot of libraries out there, but if you want a google like showcase, you can use ShowCaseView
ShowcaseViewBuilder showcaseViewBuilder;
showcaseViewBuilder = ShowcaseViewBuilder.init(this)
.setTargetView(fab)
.setBackgroundOverlayColor(0xdd4d4d4d)
.setRingColor(0xcc8e8e8e)
.setRingWidth((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()))
.setMarkerDrawable(getResources().getDrawable(R.drawable.arrow_up), Gravity.LEFT)
.addCustomView(R.layout.description_view, Gravity.TOP)
.addCustomView(R.layout.skip_layout)
.setCustomViewMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, getResources().getDisplayMetrics()));
I am working on an app which show an image which is loaded from my firebase database. I used Glide for that purpose.
I am using a button, on the click of that button a new activity will open which shows the image fetched from the url. The image load perfectly if url loaded correctly but if I cancelled in between, the app is crashing. Why it is happening and also, Is there any option to save the image in cache using glide, so that It can load it once and show without fetching it from firebase.
Here is my code to display image from url:
public void showImage(){
mStorageRef.child("TimeTable").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
#Override
public void onSuccess(Uri uri) {
url = uri.toString();
RequestOptions options = new RequestOptions().centerCrop().placeholder(R.mipmap.ic_launcher).error(R.mipmap.ic_launcher_round);
Toast.makeText(TimeTable.this, uri.toString(),Toast.LENGTH_SHORT).show();
Glide.with(TimeTable.this).load(url).apply(options).into(image);
}
});
}
Here is the Error log, when I closed the activity before image loaded completely..
Please ask if any further details are required.
You can cache your images loading using Glide. I am referring to the tutorial here where you can learn the basics of image caching using Glide.
Now about the crashing problem, it clearly says that you are trying to load something from an activity which is already destroyed. As you have a firebase listener added where you are loading the image, you need to destroy the listener as you are leaving the activity.
You might consider using onPause, onDestroy functions to handle the remove listener action. Check the removeEventListener function of Firebase.
However, I would recommend using activity scoped versions of the loaders so that Firebase task takes care of these things by itself. Please see the answer here.
I want to start the search Activity in shazam. According to this there is no search Activity to shazam, only a <provider> tag.
<provider android:name="com.shazam.android.SearchProvider" android:authorities="shazamSearchEncore" android:syncable="false" />
I tried to launch it in various ways but because this is not an Activity it failed. So how do I start shazam search? Or am i missing something in that manifest xml file?
My tries:
1:
Intent intent = new Intent("com.shazam.android.SearchProvider");
intent.putExtra("query",query);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.context.startActivity(intent);
2:
final Intent shazamIntent = new Intent(Intent.ACTION_SEARCH);
shazamIntent.setPackage("com.shazam.android.SearchProvider");
shazamIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.context.startActivity(shazamIntent );
And so on...
Also I checked these post post 1 and post 2. But found nothing helpful.
A ContentProvider can't be "launched" by intents like an Activity.
A provider is a component, designed for providing an interface to some data. The data can be accessed by a ContentResolver.
Some ContentProviders also allow access from other apps. This is usually documented somewhere, providing the URL that is needed to access the data and details about the data itself. Such an example is the Contacts provider, used to access all the contact information stored on the device.
Judging by the look of the manifest declaration of the provided that you are trying to access, I think it can only be accessed by the Shazam applications itself, so there is no way to access the data it provides.
I need some advice for this matter...
I used the facebook android sdk to create an integration with facebook from my application...I followed this tutorial:
http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/
I would need to implement authentication in one activity and the function postToWall in another.... after authentication i want to send post simply by pressing a button but in other activity, different from that where i do authentication.
is it possible? or with the SDK I'm forced to do everything together in the same activity?
thanks in advance
Yes it is possible. You will get a access token which you can send to the next activity. Use getAccessToken() and setAccessToken().
Here is an example that even saves the needed data: Contact-Picture-Sync
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
just to provide an alternative answer, there's other ways of implementing sharing on Android.
It allows for more sharing options (like Twitter, QR-Barcodes, blogging and whatnot) without having to deal with the facebook android sdk.
What you would use is a "share" intent, like so:
String title = "My thing"; // used if you share through email or channels that require a headline for the content, always include this or some apps might not parse the content right
String wallPost = "Hey - check out this stuff: http://link.com "; // the content of your wallpost
String shareVia = "Share this stuff via"; // the headline for your chooser, where the phones avaliable sharing mechanisms are offered.
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, wallPost);
startActivity(Intent.createChooser(shareIntent, shareVia));
This is by far the preferred solution on Android if you're looking for simple sharing, as it makes your app future-compatible with new services. And more lean and flexible for the user too, as there's little to no friction from hitting the share button to posting content.
It can also be seen in this blog post: http://android-developers.blogspot.com/2012/02/share-with-intents.html
I hope you can use this for your project.
How can I apply the configuration chosen by the user, in each activty of the app, without to rewrite the code in each of them?
For example, if I can use the application in fullscreen mode, now I forced to add this code in each activity
if(useFullscreen)
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
else
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Is there a way to do this?
I would suggest you to make a master activity for your app and add that code to each activity then save the configuration of user. Now you can easily apply the configuration to each page without more LOC.
http://mfarhan133.wordpress.com/2010/09/19/maser-layout-tutorial-reusing-layouts/
look above link to make master page