Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get call time duration in android ? and also multiple time write data in file?
    primarykey
    data
    text
    <pre><code> public void onCallStateChanged(int state,String incomingNumber) { System.out.print("\nState :- "+state); switch(state){ case TelephonyManager.CALL_STATE_IDLE: if(flag==true &amp;&amp; ringflag == true) { flag=false; ringflag=false; System.out.print("\nflag = " + flag); System.out.print("\nringflag = " + ringflag); stop = System.currentTimeMillis(); System.out.println("\nTotal time : " +stop); System.out.println("\nTotal time : " +(stop - start)/1000); System.out.println("\nIDLE : " + incomingNumber); long time = (stop - start) / 1000; String path = Environment.getExternalStorageDirectory().getAbsolutePath(); f = new File(path + "/sms.txt"); if (f.exists()) { try { raf =new RandomAccessFile(f, "rw"); long pointer = raf.length(); raf.seek(pointer); String data = ":-"+no+","+time; raf.writeBytes(data); raf.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { try { raf = new RandomAccessFile(f,"rw"); String data = ":-"+no+","+time; raf.writeBytes(data); raf.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } break; case TelephonyManager.CALL_STATE_OFFHOOK: if(ringflag == true) { System.out.println("OFFHOOK :- " + incomingNumber); start = System.currentTimeMillis(); System.out.print("\nStart is :-" + start); flag=true; } break; case TelephonyManager.CALL_STATE_RINGING: no = incomingNumber; System.out.println("Ringing : " + incomingNumber); ringflag= true; break; } } </code></pre>
    singulars
    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.
    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