Search code examples
androidexportsmsmms

Exporting contact activity from an android phone


Im interested in running some custom analytics on my interactions with contacts on my phone.

Some things I would like to see are:
How many times was this contact called
How long did the conversation last
How many missed calls from this contact
How many answered calls from this contact

What time and date was an sms sent
What was its message content
What time and date was an sms received
What was its message content

If it was mms can i get the picture some how
Ill use a third party api for facial recognition and nudity checks (was it a nude, selfie, meme)

Is there a way to simply export this data into a xml or csv file? (How would I save pictures?)

My goal here is to make an app using some sort of android java sdk. Then using the app, ill upload to my web server and use php to do the analytics.

Where do i look to start getting the information i want to analyze?


Solution

  • Try to look at these links:

    PhoneStateListener

    TelephonyManager

    Read SMS

    ContentResolver

    To export your pictures from mms use a filestream and a bitmap:

    private void GetMmsAttachment(String _id, String _data) 
    { 
        Uri partURI = Uri.parse("content://mms/part/" + _id ); 
        String filePath = "/sdcard/photo.jpg";
        InputStream is = null;
        OutputStream picFile = null;
        Bitmap bitmap = null;
    
        try { 
            is = getContentResolver().openInputStream(partURI); 
            bitmap = BitmapFactory.decodeStream(is);
    
            picFile = new FileOutputStream(filePath);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 50, picFile);
            picFile.flush();
            picFile.close();
        } 
        catch (Exception e) 
        { 
            e.printStackTrace(); 
            //throw new MmsException(e); 
        } 
    }
    

    Also for photo Identification I recommend you use IBM Watson,.If the photo has text use Google Tesseract to extract the text.