2017年6月19日 没有评论




<activity android:name=”.MainActivity” android:launchMode=”standard” />


1. standard


2. singleTop

如果在任务的栈顶正好存在该Activity的实例, 就重用该实例,否者就会创建新的实例并放入栈顶(即使栈中已经存在该Activity实例,只要不在栈顶,都会创建实例)。

3. singleTask


4. singleInstance


大家遇到一个应用的Activity供多种方式调用启动的情况,多个调用希望只有一个Activity的实例存在,这就需要Activity的onNewIntent(Intent intent)方法了。只要在Activity中加入自己的onNewIntent(intent)的实现加上Manifest中对Activity设置lanuchMode=“singleTask”就可以。

onNewIntent()非常好用,Activity第一启动的时候执行onCreate()—->onStart()—->onResume()等后续生命周期函数,也就时说第一次启动Activity并不会执行到onNewIntent(). 而后面如果再有想启动Activity的时候,那就是执行onNewIntent()—->onResart()——>onStart()—–>onResume().  如果android系统由于内存不足把已存在Activity释放掉了,那么再次调用的时候会重新启动Activity即执行onCreate()—->onStart()—->onResume()等。

当调用到onNewIntent(intent)的时候,需要在onNewIntent() 中使用setIntent(intent)赋值给Activity的Intent.否则,后续的getIntent()都是得到老的Intent。

分类: Android 标签: ,


2017年6月16日 没有评论

git clone***/ffmpeg.git
cd ffmpeg/
git remote -v
git remote add upstream git://
git remote -v

git fetch upstream
git checkout master
git merge upstream/master

git checkout -b dev
git push –set-upstream origin dev


分类: git, 命令 标签: ,


2017年6月7日 没有评论


chmod +x

测试结果:$ ./
Retrieving configuration…
Testing from Psychz (104.???.???.???)…
Retrieving server list…
Selecting best server based on ping…
Hosted by Time Warner Cable (Los Angeles, CA) [36.79 km]: 316.038 ms
Testing download speed……………………………………………………………………..
Download: 0.91 Mbit/s
Testing upload speed……………………………………………………………………………………
Upload: 2.81 Mbit/s


分类: Linux 标签: ,

VNC setup on Raspberry Pi from Ubuntu

2017年6月5日 没有评论

VNC setup on Raspberry Pi from Ubuntu


ssh pi@

默认用户名pi, 默认密码‘raspberry’


sudo apt-get install tightvncserver

启动VNC:vncserver :1 -geometry 1024x600 -depth 16 -pixelformat rgb565
停止VNC:vncserver -kill :1
分类: Linux 标签: , ,


2017年6月5日 没有评论

vi /etc/ssh/sshd_config

找到#Port 22一段,这里是标识默认使用22端口,修改为如下:

Port 22
Port 50000

执行/etc/init.d/sshd restart

现在编辑防火墙配置:vi /etc/sysconfig/iptables

执行/etc/init.d/iptables restart

分类: Linux 标签: ,


2017年5月12日 没有评论


* Handles secret codes to launch arbitrary activities in the form of *#*#<code>#*#*.
* If a secret code is encountered an Intent is started with the android_secret_code://<code>
* URI.
* @param context the context to use
* @param input the text to check for a secret code in
* @return true if a secret code was encountered
static boolean handleSecretCode(Context context, String input) {
// Secret codes are in the form *#*#<code>#*#*
int len = input.length();
if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
final Intent intent = new Intent(SECRET_CODE_ACTION,
Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
return true;

return false;

分类: Android 标签:


2017年5月3日 没有评论

adb root
adb remount

adb push services.jar /system/framework
adb push framework.jar /system/framework
adb push framework-res.apk /system/framework

adb push arm/boot.oat /system/framework/arm
adb push arm/ /system/framework/arm
adb push arm/boot-framework.oat /system/framework/arm
adb push arm/ /system/framework/arm

adb push arm64/boot.oat /system/framework/arm64
adb push arm64/ /system/framework/arm64
adb push arm64/boot-framework.oat /system/framework/arm64
adb push arm64/ /system/framework/arm64

adb reboot

echo off
echo YES | copy \\ip\&lt;branch1&gt;\out\target\product\&lt;product&gt;\system\priv-app\SystemUI\SystemUI.apk .
md5sum SystemUI.apk
adb push SystemUI.apk /system/priv-app/SystemUI/SystemUI.apk
adb shell am force-stop
echo on

mmm core/res &amp;&amp; mm &amp;&amp; mmm services &amp;&amp; mm

mmm -B core/res &amp;&amp; mm -B &amp;&amp; mmm -B services &amp;&amp; mm -B

分类: Android 标签: ,

How to Download/Compile Specific Parts of a ROM

2017年5月2日 没有评论

How to Download/Compile Specific Parts of a ROM

This is a tutorial about how to download and compile specific parts in AOSP based roms (such as CyanogenMod, AOKP, SlimRom etc)
It’s mainly dedicated for the people who want to get more familiar with the AOSP build environment, and would like to manipulate it’s behavior to complete specific tasks.

Downloading ROM sources is done with the tool “repo”, this is the most awesome downloader in existence. Not only it looks very cool, it also reaches top speed at all times. But it’s only for linux (which is good, since when you are busy with aosp roms, you should be on linux!)
Why is it awesome? Since you decide yourself how many jobs (aka connections) you make with the server. This means you always will get top speed, there is probably no faster download method available on the Internet (except for speedtests, but they don’t count). Next to the downloading of specific parts it’s of course also handy to know how to actually compile them.


1. Download
2. Compile

3. Automate (optional)


Chapter 1. Download:
The easiest way of fetching for example a batch of AOSP apps is like this:

1. Choose the desired tag you want to use, in the example I will use android-4.2.2_r1
2. Now make a dir somewhere:

3. Download repo when not installed yet:

4. Enter the line that will download the initial manifest.

for AOSP:

Enter your name and email address and wait until it completes

for CM:

5. Go in the hidden “.repo” dir and change the manifest

If you don’t have decent text editor such as “gedit”, install it! “sudo apt-get install gedit”


For example when you only want to download the apps, just remove all lines that are not app related. simple as that

When done, save it and go a dir back in the terminal

6. Download the packages

(With a 60mb/s connection you already get the max download speed with ” -j4 ” which is the default of github)

The packages will be download as quickly as possible to your harddrive now.


Chapter 2. Compile:
To compile the obtained packages separately you will need a AOSP environment (or CM/AOKP etc). When you have a succesfull environment which is able to compile for your device you may enter:

now you’re theoretically ready to compile
to compile an app on the easiest way:

where “Appname” is the name of the folder placed in packages/apps/..
This also counts for “SystemUI” which is not in that folder

And the -j param again stands for the number of jobs, remember that this is compiling and not downloading, so the “standard rule” with this is, number of cores of your CPU + 1.
Which makes a regular quad core (-j5) but makes a i7 CPU with Hyper threading (-j9). When using -j16 for example on a regular quad core it could happen that your CPU will be overloaded so much that your mouse will lag all over the place.
(Linux forces the cpu to perform higher then it actually should, resulting in unwanted situations)

When having trouble, when it stops or just nags about some missing symbols or something like that.
You should try using the “-k” param, this tells the make command to keep going when a non-critical error occurs.

When having issues with the local module tags, you should enter this:

To compile other parts you also need to enter the folder name, here are some examples from /frameworks/base

or more examples:


Chapter 3. Automate

If you regularly want to compile specific ROM parts you can make a shell script that automates the process for you.

Make a new document with some name, for example “buildessentials”, open the file with your favorite text editor (gedit is recommended)
and place this line at the very top of your document:

This indicates that this file should call /bin/bash, which is the shell interpreter.

Under this line you should place all the single commands that you want to be executed when running the script. For example:

So your total output would be:

Now you should change the permissions of the files, which need to be RWX-RX-RX, which is 755.
This can be done by entering this in the shell:

Now you can run the script by entering:

分类: Android 标签: ,


2017年5月1日 没有评论
curl > ~/bin/repo
chmod a+x ~/bin/repo
#AOSP download command
repo init -u
repo init -u -b android-7.1.2_r6

#lineageos download command
cd ~/android/lineage
repo init -u -b cm-14.1
repo sync -c -d -j2 --no-tags
分类: Android 标签: , ,

解决: g++: internal compiler error: Killed (program cc1plus)

2017年4月30日 没有评论

g++: internal compiler error: Killed (program cc1plus)

主要原因是内存不足,g++编译时需要大量内存, 临时使用交换分区来解决吧

sudo dd if=/dev/zero of=/swapfile bs=64M count=16

sudo mkswap /swapfile

sudo swapon /swapfile

After compiling, you may wish to


sudo swapoff /swapfile

sudo rm /swapfile

分类: Linux 标签: ,