How to take screenshot of Android(Emulator) using this library and where can i get the screenshots

℡╲_俬逩灬. 提交于 2019-12-10 06:41:15

问题


I had installed this library http://code.google.com/p/android-screenshot-library/.

I had started my Android emulator ,when i run the run.sh file it is saying "Service Started Sucessfully".

How Should i or where can i get the Screen shots of my emulator.I am using all latest versions.Thank You.


回答1:


Open Eclipse > open DDMS View > Select your Emulator out of the list > press the little blinking Camera Icon near where you select your Emulator from the list

Hope you find it.




回答2:


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
        }

    }
};
}



回答3:


DDMS has a feature to taking screenshots of views.

In Eclipse, open DDMS perspective and click on screen capture icon in Devices layout.



来源:https://stackoverflow.com/questions/9782595/how-to-take-screenshot-of-androidemulator-using-this-library-and-where-can-i-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!