Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to automatically name taken screen shots by naming them by the date of their creation?
    primarykey
    data
    text
    <p>My app takes a sequence of screenshots, but instead of getting lots of them, I get one screenshot that overwrites itself all the time. I want to get taken screenshots named by the date they were taken (it will make them unique and will solve the problem, i think). </p> <p>For that I do the following:</p> <pre><code>$(date +%m.%d.%Y-%H:%M) </code></pre> <p>Full line: </p> <pre><code>os.write(("/system/bin/screencap -p /sdcard/fly/$(date +%m.%d.%Y-%H:%M).png").getBytes("ASCII")); </code></pre> <p>But the files don't appear.</p> <p>I tried <code>/sdcard/fly/screenshot%d.png</code> but the files get named exactly like in the code "screenshot%d".</p> <p>How can I properly name my files according to the date they were taken?</p> <p>Full code:</p> <pre><code>package ru.startandroid.develop.p0921servicesimple; import java.io.IOException; import java.io.OutputStream; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; public class MyService extends Service { final String LOG_TAG = "myLogs"; public void onCreate() { super.onCreate(); Log.d(LOG_TAG, "onCreate"); } public int onStartCommand(Intent intent, int flags, int startId) { Log.d(LOG_TAG, "onStartCommand"); someTask(); return super.onStartCommand(intent, flags, startId); } public void onDestroy() { super.onDestroy(); Log.d(LOG_TAG, "onDestroy"); } public IBinder onBind(Intent intent) { Log.d(LOG_TAG, "onBind"); return null; } void someTask() { new Thread(new Runnable() { public void run() { for (int i = 1; i &lt;= 25; i++) { Log.d(LOG_TAG, "i = " + i); try { Process sh = Runtime.getRuntime().exec("su", null); OutputStream os = sh.getOutputStream(); os.write(("/system/bin/screencap -p /sdcard/fly/bob.png").getBytes("ASCII")); os.flush(); os.close(); sh.waitFor(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }).start(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload