我已經安裝了此庫http://code.google.com/p/android-screenshot-library/。如何使用此庫截取Android(模擬器)的截圖並在哪裏可以獲取屏幕截圖
我已經啓動了我的Android模擬器,當我運行run.sh文件時它說「服務開始成功」。
我該怎麼做或我在哪裏可以得到我的模擬器的屏幕截圖。我正在使用所有最新版本。謝謝。
我已經安裝了此庫http://code.google.com/p/android-screenshot-library/。如何使用此庫截取Android(模擬器)的截圖並在哪裏可以獲取屏幕截圖
我已經啓動了我的Android模擬器,當我運行run.sh文件時它說「服務開始成功」。
我該怎麼做或我在哪裏可以得到我的模擬器的屏幕截圖。我正在使用所有最新版本。謝謝。
import pl.polidea.asl.*;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.res.Resources.NotFoundException;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.graphics.*;
public class ScreenshotDemo extends Activity {
/*
* The ImageView used to display taken screenshots.
*/
private ImageView imgScreen;
private ServiceConnection aslServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
aslProvider = IScreenshotProvider.Stub.asInterface(service);
}
};
private IScreenshotProvider aslProvider = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imgScreen = (ImageView)findViewById(R.id.imgScreen);
Button btn = (Button)findViewById(R.id.btnTakeScreenshot);
btn.setOnClickListener(btnTakeScreenshot_onClick);
// connect to ASL service
//Intent intent = new Intent(ScreenshotService.class.getName());
Intent intent = new Intent();
intent.setClass(this, ScreenshotService.class);
//intent.addCategory(Intent.ACTION_DEFAULT);
bindService (intent, aslServiceConn, Context.BIND_AUTO_CREATE);
}
@Override
public void onDestroy() {
unbindService(aslServiceConn);
super.onDestroy();
}
private View.OnClickListener btnTakeScreenshot_onClick = new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
if (aslProvider == null)
Toast.makeText(ScreenshotDemo.this, R.string.n_a, Toast.LENGTH_SHORT).show();
else if (!aslProvider.isAvailable())
Toast.makeText(ScreenshotDemo.this, R.string.native_n_a, Toast.LENGTH_SHORT).show();
else {
String file = aslProvider.takeScreenshot();
if (file == null)
Toast.makeText(ScreenshotDemo.this, R.string.screenshot_error, Toast.LENGTH_SHORT).show();
else {
Toast.makeText(ScreenshotDemo.this, R.string.screenshot_ok, Toast.LENGTH_SHORT).show();
Bitmap screen = BitmapFactory.decodeFile(file);
imgScreen.setImageBitmap(screen);
}
}
} catch (NotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// squelch
}
}
};
}
1)。這段代碼將屏幕截圖緩衝區發送到無論顯示在屏幕上的電腦上2)。這個代碼應該被編譯和運行,是否應該安裝在模擬器中......實際上我的項目是ScreenCast – albert 2012-03-21 08:36:32
打開Eclipse>打開DDMS視圖>選擇您的模擬器淘汰名單>按近,你從列表中
希望你覺得它選擇模擬器的小閃爍的相機圖標。
I想要一個代碼,將啓動一個服務,將發送給我什麼顯示在模擬器(手機)到PC在一個幀緩衝區,實際上我的項目是ScreenCast – albert 2012-03-21 08:34:56
DDMS具有截取視圖截圖的功能。
在Eclipse中,打開DDMS透視圖並單擊設備佈局中的屏幕截圖圖標。
我想要一個代碼,將啓動一個服務,將發送給我無論顯示在模擬器(手機)到PC緩衝區,實際上我的項目是ScreenCast – albert 2012-03-21 08:40:05
使用eclipse IDE嗎? – Hitendra 2012-03-20 07:20:45
@Hitendra不,我直接從終端使用adb運行..我想截取手機上正在運行的任何活動的屏幕截圖。實際上我的項目是ScreenCast – albert 2012-03-21 08:33:42
嘿Albert!你有答案嗎?如果是的話,請指導。 – user1517153 2014-03-14 05:32:59