Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of IntentSender?

I want to known what is the purpose of the IntentSender class for our application? How do we use it in our application?

Are there any good examples, apart from The Android Intent Based APIs: Part Seven – IntentSenders And PendingIntents?

like image 281
ρяσѕρєя K Avatar asked Mar 06 '12 11:03

ρяσѕρєя K


1 Answers

IntentSender is kind of a level of abstraction or glue class that allows you to

  1. Receive broadcast when user selects application in chooser.

    Example when you use IntentSender:

    Intent intent = new Intent(Intent.ACTION_SEND)     .putExtra(Intent.EXTRA_TEXT, "This is my text to send.")     .setType("text/plain"); Intent receiver = new Intent(this, BroadcastTest.class)     .putExtra("test", "test"); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, receiver, PendingIntent.FLAG_UPDATE_CURRENT); Intent chooser = Intent.createChooser(intent, "test", pendingIntent.getIntentSender()); startActivity(chooser); 
  2. Start Activity with IntentSender instead of Intent (more in Android docs)

    startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options)

    Like startActivity(Intent, Bundle), but taking a IntentSender to start.

like image 198
pixel Avatar answered Oct 25 '22 15:10

pixel