2014年5月20日 星期二

[Android]記錄從開始申請Admob至銀行收到款項時間

1.2014/2/7 建立Admob帳號並開始有擊點率
2.2014/3/31 超過$20USD,使用paypal收款
3.2014/5/2 收到Admob email通知已付款$64.95USD至paypal
4.2014/5/17 收到paypal email通知已收到$64.95USD
5.2014/5/18 使用玉山銀行提領$64.95USD至玉山台幣帳戶
6.2014/5/27 收到款項

2014年5月14日 星期三

[Perl]字串運算子


String OperatorPurpose
xReturns a string consisting of the string on the left of the operand, repeated the number of times of the right operand.
Concatenates the two strings on both sides of the operator.
eqReturns True if the two operands are equivalent, False otherwise.
neReturns True if the two operands are not equal, False otherwise.
leReturns True if the operand on the left is stringwise less than the operand on the right of the operator. Returns False otherwise.
ltReturns True if the operand on the left is stringwise less than or equal to the operand on the right of the operator. Returns False otherwise.
geReturns True if the operand on the left is stringwise greater than or equal to the operand on the right of the operator. Returns False otherwise.
gtReturns True if the operand on the left is stringwise greater than the operand on the right of the operator. Returns False otherwise.
cmpReturns -1, 0, or 1 if the left operand is stringwise less than, equal to, or greater than the right operand.
,Evaluates the left operand, the evaluates the right operand. It returns the result of the right operand.
++Increments the string by one alphabetic value.

2014年5月5日 星期一

[Android]Textview autoresize,字動設定自體大小

參考http://stackoverflow.com/questions/16017165/auto-fit-textview-for-android
建立一個AutoResizeTextView.java
將link中的source放進去都不用修改,很實用

[Android]調整TextView字體大小

下面紅色字體,要使用sp

<TextView
    android:id="@+id/textView"
    ...
    ......    android:textSize = "80sp"      
    android:text="TextView" />

[Android]新版Admob

當你的Admob網頁最上方出現新版的Admob,如果你是使用paypal收款,請不要更新
因為更新後不接受paypal收款
等了好久的64.95美元終於入帳了,只是之後都不能使用paypal,真是手X


2014年4月13日 星期日

[Android]跳至play.google.com

// Search application
Uri uri = Uri.parse("market://search?q=pname:package name");  
Intent it = new Intent(Intent.ACTION_VIEW, uri);  
startActivity(it);  
//show application's detail page
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=package name"));
startActivity(intent);
startActivity(new Intent("android.intent.action.VIEW",
Uri.parse("https://play.google.com/store/apps/details?id=com.xxxxxx")));

2014年4月3日 星期四

[Android]Paypal

1.paypal 測試環境中文教學pdf
https://www.paypal-marketing.com/paypal/html/partner/tw/zh/RS/PayPal_Sandbox_Guidebook.pdf 

主要
1.至github下載PaypalSDKExample做測試
2.要產生CLIENT_ID
3.要修改 PayPalConfiguration.ENVIRONMENT_SANDBOX;

[Android]Fart Sample

1.在res/drawable建立
fart_button1.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/mushroom_cloud"    -->於click button後button換變成res/drawable的mushroom_cloud的圖案
          android:state_pressed="true" />
 
    <item android:drawable="@drawable/fart1" />   -->原本的圖案
</selector>

2.main.xml 編排的方式
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.androidbook.Fart"

    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/toiletexplosion">
 
<TableLayout
        android:id="@+id/TableLayout01"
        android:stretchColumns="*"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent">
        <TableRow
            android:id="@+id/TableRow00"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal">
        <ImageView
        android:src="@drawable/title_seethrough"
        android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:id="@+id/titlebanner"
        ></ImageView>

</TableRow>
 </TableLayout>

 <TableLayout
 android:id="@+id/TableLayout02"
        android:stretchColumns="*"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        >
  <TableRow
            android:id="@+id/TableRowad"
            android:layout_height="20px"
            android:layout_width="200px"
            android:layout_gravity="center_vertical|center_horizontal">
        <com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"/>
</TableRow>
        </TableLayout>

    <TableLayout
        android:id="@+id/TableLayout03"
        android:stretchColumns="*"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_marginTop="20px">
        <TableRow
            android:id="@+id/TableRow01"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal">  
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:id="@+id/b1"
     android:background="@drawable/fart_button1"
     android:onClick="playFartOne" />
   
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:id="@+id/b2"
     android:background="@drawable/fart_button2"
     android:onClick="playFartTwo" />
   
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:id="@+id/b3"
     android:background="@drawable/fart_button3"
     android:onClick="playFartThree" />
   
</TableRow>

<TableRow
            android:id="@+id/TableRow02"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal">
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:background="@drawable/fart_button4"
     android:onClick="playFartFour" />
   
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:background="@drawable/fart_button5"
     android:onClick="playFartFive" />                  
   
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:background="@drawable/fart_button6"
     android:onClick="playFartSix" />                  
   
</TableRow>

<TableRow
            android:id="@+id/TableRow02"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal">
   
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:background="@drawable/fart_button7"
     android:onClick="playFartSeven" />
   
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:background="@drawable/fart_button8"
     android:onClick="playFartEight" />                  
   
<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:background="@drawable/fart_button9"
     android:onClick="playFartNine" />                  
   
     </TableRow>
     </TableLayout>

</LinearLayout>

2014年3月11日 星期二

[Linux]網卡MAC Address查詢方式

1. ifconfig -a
2. cat /sys/class/net/ethx/address
3. cat /proc/net/arp

[Linux]網卡出現__tmp472800901

1.ifconfig -a中看到網卡名稱為
__tmp472800901

2.應該是在ifcfg-ethx中的HWADDR=xx:xx:xx:xx:xx:xx設定錯誤或是沒有設定,補上後重開機

2014年3月5日 星期三

[Android]VFY: unable to find class referenced in signature

03-04 11:21:10.332: W/dalvikvm(1508): VFY: unable to find class referenced in signature (Lcom/android/volley/toolbox/ImageLoader;)
03-04 11:21:10.332: I/dalvikvm(1508): Could not find method com.android.volley.toolbox.Volley.newRequestQueue, referenced from method com.evancharlton.folly.FollyApp.onCreate
03-04 11:21:10.342: W/dalvikvm(1508): VFY: unable to resolve static method 5059: Lcom/android/volley/toolbox/Volley;.newRequestQueue (Landroid/content/Context;)Lcom/android/volley/RequestQueue;
03-04 11:21:10.342: D/dalvikvm(1508): VFY: replacing opcode 0x71 at 0x0005

處理方式:
java Build Path -->Order and Export ,把第三方jar句選起來

2014年2月22日 星期六

[Android]反組譯APK檔(decompiler)

1.先將apk複製一份並改副檔名為.zip
2.將0115.zip解壓縮
3.D:\android\decode\dex2jar>dex2jar.bat D:\android\apk\0115\classes.dex
4.D:\android\apk>apktool.jar d 0115.apk 0115_apk_tool
5.D:\android\apk\0115\classes_dex2jar.jar 使用jd-gui開啟
7.將D:\android\apk\jad.exe複製到D:\android\apk\0115\classes_dex2jar\tw\fmbase\lantern\
8.D:\android\apk\0115\classes_dex2jar\tw\fmbase\lantern>jad.exe *.class
9.產生*.jad檔案,可使用UltraEdit開啟

[Linux]KILL PROCESS

1.
先找出process id
ps -ef | grep vsftpd
kill process
kill -9 pid

2.
先找出process id
pgrep vsftpd
kill process
pkill vsftpd

[Linux]TCP/UDP Port是否有在使用

要知道TCP/UDP Port使用有被占用,可使用telnet
TCP
telnet ip port
有人使用會出現
Escape character is '^]'
UDP
nc -zu ip port
有人使用會出現
Connection to ip port [udp....] succeeded

2014年2月20日 星期四

[AIX]修改網卡速度

在AIX上修改網卡速度方式

確認那些是真的網卡
#lsdev -Cc adapter | grep ent

可確認pci位置
#lsslot -c pci| grep ent

看詳細資訊
#lscfg -v | ent0

開始修改網卡速度
smit enet --> adapter -->Change / Show Characteristics of an Ethernet Adapter --> ent0
--> Requested media speed --> select 1.Auto_Negotiation or 1000_Full_Duplex

P.S.如果有設定etherchannel,須先將etherchannel移除

2014年2月17日 星期一

[Android]My First App Source Code

hair dryer
link : https://play.google.com/store/apps/details?id=com.joe.fantahairdryer


MainActivity.java
package com.joe.fantahairdryer;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends Activity {
    private  void stopPlaying() {
          if (play !=null){
            play.stop();
            play.release();
            play = null;
        }
    
    }
    private Button btn1, btn2, btn3, stop;
    private MediaPlayer play;
    
    @Override
    public  void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        btn1 =    (Button)findViewById(R.id.btn1);
        btn1.setOnClickListener(new View.OnClickListener() 
        {        
            @Override
            public void onClick(View v) 
            {
             stopPlaying();
             LinearLayout  linearLayout = (LinearLayout) findViewById(R.id.container);
             linearLayout.setBackgroundResource(R.drawable.btn1);            
                play = MediaPlayer.create(MainActivity.this, R.raw.btn1);
                play.setLooping(true);                
                   if(play.isPlaying() == false)
                    {
                        play.start();  
                    }
                    else
                    {
                        play.stop();
                    }
            }

                        
        });
        btn2 =    (Button)findViewById(R.id.btn2);
        btn2.setOnClickListener(new View.OnClickListener() 
        {        
            @Override
            public void onClick(View v) 
            {
                stopPlaying();
                 LinearLayout  linearLayout = (LinearLayout) findViewById(R.id.container);
                 linearLayout.setBackgroundResource(R.drawable.btn2);
                play = MediaPlayer.create(MainActivity.this, R.raw.btn2);
                play.setLooping(true);     
                if(play.isPlaying() == false)
                    {
                        play.start();  
                    }
                    else
                    {
                        play.stop();
                    }
            }
                        
        });
        btn3 =    (Button)findViewById(R.id.btn3);
        btn3.setOnClickListener(new View.OnClickListener() 
        {        
            @Override
            public void onClick(View v) 
            {
                stopPlaying();
                 LinearLayout  linearLayout = (LinearLayout) findViewById(R.id.container);
                 linearLayout.setBackgroundResource(R.drawable.btn3);
                play = MediaPlayer.create(MainActivity.this, R.raw.btn3);
                play.setLooping(true);    
                if(play.isPlaying() == false)
                    {
                        play.start();  
                    }
                    else
                    {
                        play.stop();
                    }
            }
                        
        });
        stop =    (Button)findViewById(R.id.stop);
        stop.setOnClickListener(new View.OnClickListener() 
        {        
            @Override
            public void onClick(View v) 
            {            
                play.stop();

            }
                        
        });


    }
    @Override
    protected void onDestroy() {
        if(play !=null && play.isPlaying()) {
            play.stop();
            play.release();
            play = null;
        }
        super.onDestroy();
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    android:gravity="bottom"
    android:orientation="vertical"
    tools:context=".MainActivity"
    tools:ignore="MergeRootFrame" >

    <Button
        android:id="@+id/stop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="STOP" />

    <Button
        android:id="@+id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hair Dryer1" />

    <Button
        android:id="@+id/btn2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hair Dryer2" />

    <Button
        android:id="@+id/btn3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hair Dryer3" />
    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="xxxxxxx"
        ads:loadAdOnCreate="true"
        android:gravity="bottom" >
    </com.google.ads.AdView>




</LinearLayout>

This is layout