Showing posts with label random. Show all posts
Showing posts with label random. Show all posts

How to Generate a kernel log after random reboot

| 0 comments |
Once in a while, a software bug in the kernel will cause a random reboot, so in order to help kernel developers to fix and troubleshoot the reboots, a kernel log need to be submitted to the developer for further analysis and hopefully lead to a bug fix.

Most Android kernels have "RAM Consoles" to save the necessary kernel logs immediately after reboot in the RAM.  The users can then retrieve this RAM log on a subsequent reboot to submit to kernel developers. Here is a quick tour on how to do that.


[ Using ADB ]
  1. adb shell
  2. su
  3. cat /proc/last_kmsg > /sdcard/last_kmsg.txt
  4. exit
  5. exit
  6. adb pull /sdcard/last_kmsg.txt
File last_kmsg.txt will be located in the same location as adb.exe executable.


[ Using android terminal app ]
  1. su
  2. cat /proc/last_kmsg > /sdcard/last_kmsg.txt
  3. exit
  4. exit
  5. adb pull /sdcard/last_kmsg.txt
File last_kmsg.txt will be located on your SD-card.


[ Using Root Explorer / ES Explorer with Root ]
  1. go to /proc folder
  2. copy last_kmsg to /sdcard/
  3. rename last_kmsg to last_kmsg.txt
File last_kmsg.txt will be located on your SD-card.

The best method to share the last_kmsg.txt content is to upload it to pastebin.com and send a link to the developer.

Source: faux123 (Google +)

Have any questions or comments? Feel free to share! Also, if you like this article, please use media sharing buttons (Twitter, G+, Facebook) below this post!
Read More..

Generate random String using org apache commons lang3 RandomStringUtils

| 0 comments |

This example show how to generate random String using org.apache.commons.lang3.RandomStringUtils.

You have to download Apache Commons Lang, and add the jar to Android Studio Projects libs. Refer to the video.


package com.blogspot.android_er.androidrandomstring;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import org.apache.commons.lang3.RandomStringUtils;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button btnGenerate = (Button)findViewById(R.id.gen);
final TextView textResult = (TextView)findViewById(R.id.result);

btnGenerate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
textResult.setText("");
for(int i=1; i<20; i++){
String randomString = RandomStringUtils.randomAlphabetic(i) + " ";
textResult.append(randomString);
}
}
});

}
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout


android_layout_width="match_parent"
android_layout_height="match_parent"
android_paddingBottom="16dp"
android_orientation="vertical"
tools_context="com.blogspot.android_er.androidrandomstring.MainActivity">

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold" />

<Button
android_id="@+id/gen"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_text="Generate Random Strings"/>

<TextView
android_id="@+id/result"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_typeface="monospace"
android_textSize="22sp"/>
</LinearLayout>



Read More..