SoundPool的使用以及登录密码

float j = 1.0f; 

SoundPoolsp=null;

intsID=0;

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);(R.layout.main);

Buttonb=(Button)findViewById(R.id.Button01);

b.setOnClickListener(newOnClickListener(){

@Override

publicvoidonClick(Viewv){

j=(float)(j+.5f);

sp.setRate(sID,j);

}

});

AssetFileDescriptorafd;

try{

sp=newSoundPool(1,AudioManager.STREAM_MUSIC,0);

afd=getAssets().openFd("wav/sample.wav");

intid=sp.load(afd,1);

sID=sp.play(id,1,1,1,0,j);

}catch(IOExceptione){

//TODOAuto-generatedcatchblock

e.printStackTrace();

}

}

为了改变 rate of play afterward 必须使用sp.setRate(StreamID,j)

    setContentView

而且“每一个pool最多1M”

更好的处理方法http://code.google.com/p/libgdx/

2.URL url = new URL("https://acme.com.au/your_account/index.php?function=login"); 

HttpURLConnectionconn=(HttpURLConnection)url.openConnection();

//Ifyouneedacookiefrompreviousrequests

//conn.setRequestProperty("Cookie","JSESSIONid="+encode(jSessionId,"UTF-8"));

conn.setRequestProperty("If-Modified-Since","Sat,1Jan200000:00:00GMT");

conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

conn.setRequestMethod("POST");

conn.setDoOutput(true);

conn.setDoInput(true);

DataOutputStreamout=newDataOutputStream(conn.getOutputStream());

out.writeBytes(String.format("check_username=%s&password=%s",

URLEncoder.encode(PERSNR,"UTF-8"),

URLEncoder.encode(PASSWD,"UTF-8")));

out.close();

//Ihaveabsolutelynoideawhythisisneeded.

InputStreamis=conn.getInputStream();

//...readtheresponsefromis.

is.close();

相关推荐