Advertisement
tic0

at-command-android-progg

Oct 10th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.InputStream;
  3.  
  4. import android.app.Activity;
  5. import android.os.Bundle;
  6.  
  7. public class ProvaAtCommandsActivity extends Activity {
  8.     /** Called when the activity is first created. */
  9.     @Override
  10.     public void onCreate(Bundle savedInstanceState) {
  11.         super.onCreate(savedInstanceState);
  12.         setContentView(R.layout.main);
  13.         ReadCPUinfo();
  14.  
  15.     }
  16.  
  17.     private void ReadCPUinfo() {
  18.         ProcessBuilder cmd;
  19.         String result = "";
  20.  
  21.         try {
  22.  
  23.             String[] args = { "/system/bin/service",
  24.                     "call", "phone", "2", "s16", "+393274296037" };
  25.             cmd = new ProcessBuilder(args);
  26.  
  27.             Process process = cmd.start();
  28.             InputStream in = process.getInputStream();
  29.  
  30.             byte[] re = new byte[1];
  31.  
  32.                 while (in.read(re) != -1) {
  33.                     result = result + new String(re);
  34.                 }
  35.  
  36.             in.close();
  37.  
  38.         } catch (IOException ex) {
  39.  
  40.             ex.printStackTrace();
  41.         }catch(Exception e){
  42.  
  43.         }
  44.  
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement