Remove operator boot animation i.e. plus in Android – Samsung device

First of all You should have root on device, second be able to change your partition on android device to status as: writeable (posted few posts ago what is the command for it).

I assume all is set. Now go in adb shell as a root to : /system/media/

When You call to list files, You will get two interesting files:

-rw------- root     root        69056 2016-12-26 01:42 bootsamsung.qmg
-rw-r--r-- root     root        69056 2016-06-02 17:23 bootsamsungloop.qmg

First is the first static or animating animation, second is the loop. Usually it is like:

-show anoying operator animation
-show after that samsung animation

What to do is to backup first file, and copy the second one but renaming it like the backuped file, which is here “bootsamsung”.

As a result there will be two files as above, but both will do the same animation.

Notepad++ with regex, re-using match variables

Here is an simple example how to use regex in notepad++ with reusing selected match variables.

For example we have special code for simulating gcm notifications. We would like to see it in pretty style.
To achieve this we must to move all elements with minus to the new lines. How to do it? Here is the solution.

We have this string:
adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -c com.example.android.debug -n com.example.android.google.debug/com.example.android.gcm.GcmBroadcastReceiver --es "aaa" "123" --es "mmm" "bla bla bla" --es "sss" "321" --es "from" "111" --es "type" "yesterday" --es "collapse_key" "do_not_collapse"

By using bellow command in notepad++:

Searching text:

\-[a-z]{0,2}\s

Replace with:

\n($0)

We get the quite pretty result:

adb shell am broadcast
-a com.google.android.c2dm.intent.RECEIVE
-c com.example.android.debug
-n com.example.android.google.debug/com.example.android.gcm.GcmBroadcastReceiver
--es "aaa" "123"
--es "mmm" "bla bla bla"
--es "sss" "321"
--es "from" "111"
--es "type" "yesterday"
--es "collapse_key" "do_not_collapse"

Change time in genymotion emulator – simple java app

I made app in executable jar java file for setting time in genymotion emulator.

Here is simple java code and compiled app for setting time in genymotion app. Below code I showed how the app looks like and also added ready jar app to download.

Code:

public class SetTimeInGenyMotion {
private JTextField textField1;
private JButton getTimeInProperButton;
private JButton setTimeInProperButton;
private JButton getTimeAndSetButton;
private JPanel panel1;
public static final String FORMAT = "YYYYMMDD.HHmmss";

public static void main(String[] args) {
new SetTimeInGenyMotion().doStuff();
}

private void doStuff() {

getTimeInProperButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textField1.setText(getTime());
}
});

setTimeInProperButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String time = textField1.getText();
setTime(time);
}
});

getTimeAndSetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String time = getTime();
setTime(time);
textField1.setText(time);
}
});

showWindow();
}

private void showWindow() {
JFrame frame = new JFrame("SetTimeInGenyMotion");
frame.setContentPane(panel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(680, 0));
frame.pack();
frame.setVisible(true);
}

private void setTime(String time) {
try {
String command = "adb shell date -s " + time;

Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(pr.getErrorStream(), "UTF-8"));
String l = "";

while ((l = br.readLine()) != null) {
System.out.println(l);
}
br.close();

} catch (IOException e1) {
e1.printStackTrace();
}
}

private String getTime() {
//adb shell date -s YYYYMMDD.HHmmss
//http://stackoverflow.com/questions/7094772/how-to-set-android-device-date-time-programmatically

String format = "YYYYMMdd.HHmmss";
Calendar instance = Calendar.getInstance();
String time = getDate(instance.getTimeInMillis(), format);
return time;
}

public static String getDate(long milliSeconds, String dateFormat) {
// Create a DateFormatter object for displaying date in specified format.
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
// Create a calendar object that will convert the date and time value in milliseconds to date.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
}
}

Pic:
Zrzut ekranu 2015-06-03 11.58.59

Download:
download

Working example – changing drawable background in runtime, dynamically

Here is a short example code how to do it:
I’ve created xml file shape.xml and one method for flexible changing color of shape.

shape.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@android:color/holo_blue_bright" />
<corners android:radius="30dp" />
<size
android:height="15dp"
android:width="15dp" />
</shape>

And here is a method for flexible changing color:

Continue reading “Working example – changing drawable background in runtime, dynamically”

Smaller ratingboard with clickable area

During my one day project for a client I had to use (I hate it) android’s ratingbar component. One of the pointed task in project was to use a bit smaller object with 5 stars than it is as default. What is more it had to be place it in every item in listview.
So what’s the problem? “All you have to do is to use param

style="?"

” – I thought. But it has not been the final solution yet..

Continue reading “Smaller ratingboard with clickable area”