Created
February 11, 2014 19:26
-
-
Save jaredsburrows/8942232 to your computer and use it in GitHub Desktop.
GoogleFeedbackUtils - Google's Feedback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.ComponentName; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.ServiceConnection; | |
import android.os.Binder; | |
import android.os.IBinder; | |
import android.os.Parcel; | |
import android.os.RemoteException; | |
import android.util.Log; | |
/** | |
* Utilities for Google Feedback. | |
* | |
* @author Jimmy Shih | |
*/ | |
public class GoogleFeedbackUtils { | |
private static final String TAG = GoogleFeedbackUtils.class.getSimpleName(); | |
private GoogleFeedbackUtils() {} | |
/** | |
* Binds the Google Feedback service. | |
* | |
* @param context the context | |
*/ | |
public static void bindFeedback(Context context) { | |
Intent intent = new Intent(Intent.ACTION_BUG_REPORT); | |
ServiceConnection serviceConnection = new ServiceConnection() { | |
@Override | |
public void onServiceConnected(ComponentName name, IBinder service) { | |
try { | |
service.transact(Binder.FIRST_CALL_TRANSACTION, Parcel.obtain(), null, 0); | |
} catch (RemoteException e) { | |
Log.e(TAG, "RemoteException", e); | |
} | |
} | |
@Override | |
public void onServiceDisconnected(ComponentName name) {} | |
}; | |
// Bind to the service after creating it if necessary | |
context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment