How to detect phone shaking in Android. Sample

Here is sample application which demonstrate shake detecting. This sample application go into red when shake detected. Please look youtube video. package com.hrupin.sample.shakedetect; import android.app.Activity; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.view.View; import android.widget.RelativeLayout; import android.widget.TextView; import java.security.cert.CollectionCertStoreParameters; public class MainActivity extends Activity Read more…

Send email with text file as attachment android sample

Here is little sample how to send email (send intent to MailĀ app) with text file as attachment. Screenshot:   And here is source code of main feature: private void sendIntentToGmailApp(File fileToSend) { if(fileToSend != null){ Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_SUBJECT, “Send Text File As Attachment Example”); email.putExtra(Intent.EXTRA_TEXT, emailBody); email.putExtra(Intent.EXTRA_STREAM, Read more…

How to create custom style for fast scroll scrollbar in Android

Here is sample for fastScroll ListView functionality. To apply this style you need add the following lines into your app’s style: <item name=”android:fastScrollThumbDrawable”>@drawable/fastscroll_drawable</item> <item name=”android:fastScrollOverlayPosition”>atThumb</item> <item name=”android:fastScrollTrackDrawable”>@drawable/track_fastscroll</item> Also if you need handle click action on your scrollbar you need create the next drawable: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android” > <item Read more…