How to dump Intent Content into Logcat

0
User Management System
Learn Kotlin, Retrofit, MVVM and MySQL using this all-in-one app. It is designed to be beginner friendly.

We use intents to pass messages and content in android and sometimes you want to dump that content in the logcat for debugging purposes. This piece explores how to do it using an open source library.

Step 1: Installation

Install the library from jcenter:

implementation 'com.drivemode:IntentLogger:1.0.5@aar'

Step 2: Code

Then call the dump method of the IntentLogger class:

public class MainActivity extends Activity {
    public static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        IntentLogger.dump("test", getIntent());
    }
}

Result

Here is the log result:

app V/test﹕ Intent[172e5d96] content:
app V/test﹕ Action   : android.intent.action.MAIN
app V/test﹕ Category : {android.intent.category.LAUNCHER}
app V/test﹕ Data     : null
app V/test﹕ Component: com.drivemode.intentlog.app/com.drivemode.intentlog.app.MainActivity
app V/test﹕ Flags    : 10000001100000000000000000000
app V/test﹕ Flag     : FLAG_RECEIVER_FOREGROUND
app V/test﹕ Flag     : FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
app V/test﹕ Flag     : FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
app V/test﹕ HasExtras: true
app V/test﹕ Extra[profile] :0

 

That's it.

Links

  1. Download Code here.
  2. Thanks to @Drivemode for this example.

 

 

Android MySQL Retrofit2 Multipart CRUD,Search,Pagination rating

When I was a 2nd year Software Engineering student, I buillt a now defunct online tool called Camposha(from Campus Share) using my then favorite language C#(ASP.NET) to compete OLX in my country(Kenya). The idea was to target campus students in Kenya. I got a few hundred signups but competing OLX proved too daunting. I decided to focus on my studies, learning other languages like Java,Python,Kotlin etc while meanwhile publishing tutorials at my YouTube Channel ProgrammingWizards TV which led to this site(camposha.info). Say hello or post me a suggestion: oclemmi@gmail.com . Follow me below; Github , and on my channel: ProgrammingWizards TV

We will be happy to hear your thoughts

Leave a reply

seventy six − = 69

Reset Password
Compare items
  • Total (0)
Compare
0
Shopping cart