Скриншоты.

Ответить
armanbisembaev
Сообщения: 3
Зарегистрирован: 11 окт 2014, 19:19

Скриншоты.

Сообщение armanbisembaev » 13 май 2015, 15:42

Ребята, мне нужно делать скриншоты того что видит пользователь, даже если он скрыл приложение или открыл другое.
Но у меня получается захватывать только своё приложение.
Права суперпользователя вроде как выдаются.

Что я делаю не так?

Код: Выделить всё

Runnable runnable = new Runnable() {
	        public void run() {
	        	try {
	    			Process proc = Runtime.getRuntime().exec(true ? "su" : "sh");
	    		} catch (IOException e) {
	    			e.printStackTrace();
	    		}

	        	File savePath = Environment.getExternalStorageDirectory();
        		savePath = new File(savePath.getAbsolutePath() + "/" + DIR);
        		savePath.mkdirs();

	        	i = 0;
	        	while (i < 20) {
		        	try {
		        		View currentRootView = getWindow().getDecorView().getRootView().getRootView();

		        		currentRootView.setDrawingCacheEnabled(true);  	
		        		Bitmap bm = currentRootView.getDrawingCache(); 
		        		int width = bm.getWidth();						
		        		int height = bm.getHeight();					
		        		Bitmap bm_half = Bitmap.createScaledBitmap(bm, width, height, false);  
		        		currentRootView.setDrawingCacheEnabled(false);	
		        		OutputStream fout = null;
		        		File imageFile = new File(savePath, FILENAME + i + ".jpg");
		        		try {
		        			fout = new FileOutputStream(imageFile);
		        			bm_half.compress(Bitmap.CompressFormat.JPEG, 90, fout);
		        			fout.flush();
		        			fout.close();
		        		} catch (IOException exc) {
		        			exc.printStackTrace();
		        		}        		
		        		Thread.sleep(1000);	
					} catch (Exception e) {
						e.printStackTrace();
					}
		        	i++;
	        	}
	        }
	    };

Ответить