sendBroadscast VS startActivity. What is the difference?

前端 未结 1 1296
星月不相逢
星月不相逢 2021-01-21 11:49

What is the differents between sendBroadcast (intent) to startActivity(intent).

Why this don\'t work:

Intent smsIntent = new Intent(Intent.ACTION_SENDTO)         


        
相关标签:
1条回答
  • 2021-01-21 11:54

    sendBroadCast() sends a global broadcast that is to be picked up by any BroadcastReceivers that are set to receive that broadcast.

    startActivity() attempts to start an Activity based on either the class name you specify or the Intent Action (which is a String).

    In your case Intent.ACTION_SENDTO is an Intent Action and so, needs startActivity()

    From the docs:

    Standard Activity Actions

    These are the current standard actions that Intent defines for launching activities (usually through startActivity(Intent). The most important, and by far most frequently used, are ACTION_MAIN and ACTION_EDIT.

    0 讨论(0)
提交回复
热议问题