riul88 / call-recorder-for-android

call-recorder-for-android fork
159 stars 99 forks source link

Not able to record calls in Android 4.1.1 #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for the Great app. It works fine with Android 2.3(Gingerbread) but 
doesn't work with android 4.1.1. Details are given below for reference.

What steps will reproduce the problem?
Install the app in device which has Android 4.1.1 (Jelly Bean). The app says 
"Unfortunately, cannot record audio on this device". The same apk is working on 
Android 2.3.6 (Gingerbread)

What is the expected output? What do you see instead?
To record calls seamlessly in Android 4.1

What version of the product are you using? On what operating system?
Android 4.1.1 - Sony xperia E Dual (C1604) [App is not working]
Andorid 2.3.6 - Samsung Galaxy Ace Duos S6802 [App is work good]

Please provide any additional information below.
The log says "Start Failed".
call recorder Exception: Start Failed.
android.media.MediaRecorder.start(Native Method)
com.android.RecordService.onStartCommand(RecordService.java:139)
...

Please let know how can we use the app on Android 4.1

Thanks,
Muthu.

Original issue reported on code.google.com by dealsfor...@gmail.com on 5 Sep 2013 at 12:22

GoogleCodeExporter commented 9 years ago
Hi.
I have the same issue on a Nexus 5 with Android 4.4.4.
The error message is "Unfortunately, it is not possible to record calls in this 
device".

Aurelien.

Original comment by aurelien...@gmail.com on 19 Aug 2014 at 12:50

GoogleCodeExporter commented 9 years ago
I have same problem with Samsung Note III, 4.4.2.
It shows title list, but there is no file /recordedCalls.

Kemal

Original comment by kemal.m...@gmail.com on 24 Aug 2014 at 3:38

GoogleCodeExporter commented 9 years ago
i am looking for same issues .please let me know if you have any solution .

my mail id is rameshandroid99@gmail.com 

Original comment by rameshan...@gmail.com on 18 Sep 2014 at 1:35

GoogleCodeExporter commented 9 years ago
I have the same issue with Lenovo A390, 4.0.4 
its making a RuntimeException.

Original comment by shaj...@gmail.com on 10 Nov 2014 at 7:51

GoogleCodeExporter commented 9 years ago
Issue with Samsung Galaxy Pocket runs on 2.2 version. It could not save the 
recorded file.

Original comment by shaj...@gmail.com on 10 Nov 2014 at 8:42

GoogleCodeExporter commented 9 years ago
moto g with root android 4.4.4same issue

Original comment by danjor...@gmail.com on 26 Nov 2014 at 11:12

GoogleCodeExporter commented 9 years ago
I'm using app version 2.0.3 downloaded from f-droid. My device is Samsung 
Galaxy S3 GT-I9300, android version is 4.3

I start the application and enable call recording. When a call starts, I get a 
notification from the app that it started recording. When the call ends, I also 
get a notification that recording ended.

Opening the app, it shows a list of previous calls to choose from.

However, the recordedCalls folder is empty. There are no files (no hidden files 
either).

Original comment by itays...@gmail.com on 1 Dec 2014 at 9:29

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
app from google play is working fine for me which was updated on january 2014. 
I found that when i compiled apk from source code the recording files are not 
getting created in recordedcall folder.
I think RecordService.java has been changed after that. See url to see 
difference.
I changed below line and its working fine for me, I dont know the difference 
but at least anyone can give it a try.

http://code.google.com/p/call-recorder-for-android/source/diff?path=/Android+Cal
l+Recorder/src/com/call/recorder/RecordService.java&format=side&r=52

String filepath = Environment.getExternalStorageDirectory().getAbsolutePath() 
//OR getPath();

Original comment by tejankar...@gmail.com on 6 Jan 2015 at 8:46

riul88 commented 9 years ago

Updated recording functionality to stop most of the issues, but would require to test on each devices to validate, there are documented issues on some phone models due to hardware/firmware or android roms restrictions

revuwa commented 9 years ago

Thanks a lot for continuing the Call Recoder development for newer Android versions!

It seems, that I've the same problem on my device:

The message:

failure

CatLog:

[filtered to: 'Call recorder']

D (28822): MyPhoneReciever phoneNumber ************
D (28822): RecordService onStartCommand
D (28822): RecordService STATE_INCOMING_NUMBER
D (28822): RecordService startService
D (28822): MyPhoneReciever phoneNumber null
D (28822): RecordService onStartCommand
D (28822): RecordService STATE_CALL_START
D (28822): RecordService startRecording
E (28822): Exception
D (28822): RecordService terminateAndEraseFile
D (28822): RecordService stopAndReleaseRecorder
E (28822): IllegalStateException
D (28822): RecordService deleteFile
D (28822): FileHelper deleteFile /storage/sdcard0/recordedCalls/d*******p*********.3gp
D (28822): RecordService deleteFile
D (28822): MyPhoneReciever phoneNumber null
D (28822): RecordService onStartCommand
D (28822): RecordService STATE_CALL_END
D (28822): RecordService stopService
D (28822): RecordService onDestroy
D (28822): RecordService stopService

If there is a simple way to get that awesome app to work, it would be so great.

Thanks to everyone with a hint for me/us and thanks again to the developer(s) for your enthusiasm!

GreenLunar commented 9 years ago

Maybe related to #23

champrocks3190 commented 8 years ago

i found the solution for it to be work on marsh mallow also , the point is in code used

the source as voice call ,, but we have to change it to mic

in RecordService.java change the line as below

I'm attaching code , here but i also notice that all player can not play it , as its boz 3gp format , but uc video is playing it , and u can notice its also recording with some content into it and not 0.00 byte

other thing is press cltr + f and find delete and make comment for delete method and where ever u find the delete ,

please notify me if u have any issue ;

picsart_08-20-02 41 56 picsart_08-20-02 43 08

screen shot 2016-08-20 at 2 44 32 pm screen shot 2016-08-20 at 2 48 45 pm


im pasting code here coz it don't alsow me sublime file as its txt


RecordService.java :-


package entertainment.college.com.xmmozikrecorder;

import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.os.Environment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; import android.widget.Toast;

import java.io.File; import java.io.IOException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List;

public class MyCallsAdapter extends ArrayAdapter {

private final Context context;
private List<Model> list;

public MyCallsAdapter(Context context, List<Model> list) {
    super(context, R.layout.rowlayout, list);
    this.list = list;
    this.context = context;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View rowView = inflater
            .inflate(R.layout.rowlayout, parent, false);
    final TextView textView = (TextView) rowView
            .findViewById(R.id.label_list);
    final TextView textView2 = (TextView) rowView
            .findViewById(R.id.label_list_2);

/* final Button btp=(Button) rowView.findViewById(R.id.buttonplay); btp.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            MediaPlayer mPlayer=new MediaPlayer();
            Uri intentUri= Uri.parse("file://"
                    + context.getFilesDir().getAbsolutePath() + "/"
                    + Constants.FILE_DIRECTORY + "/recordedCalls/d20160820185552p919825112480.mp3");

            mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

            try {
                mPlayer.setDataSource(Environment.getExternalStorageDirectory().getPath()+"/recordedCalls/");
            } catch (IllegalArgumentException e) {
                Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
            } catch (SecurityException e) {
                Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
            } catch (IllegalStateException e) {
                Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                mPlayer.prepare();
            } catch (IllegalStateException e) {
                Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
            } catch (IOException e) {
                Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
            }

            mPlayer.start();

        }
    });

*/

    // final ImageView imgDelete =
    // (ImageView)rowView.findViewById(R.id.img_delete);
    String getCallName = list.get(position).getCallName();
    String myDateStr = getCallName.substring(1, 15);
    SimpleDateFormat curFormater = new SimpleDateFormat("yyyyMMddkkmmss");

    Date dateObj = new Date();
    try {
        dateObj = curFormater.parse(myDateStr);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    textView2.setText(DateFormat.getDateInstance().format(dateObj) + " "
            + DateFormat.getTimeInstance().format(dateObj));
    String myPhone = getCallName.substring(16, getCallName.length() - 4);

    if (!myPhone.matches("^[\\d]{1,}$")) {
        myPhone = context.getString(R.string.withheld_number);
    } else if (list.get(position).getUserNameFromContact() != myPhone) {
        myPhone = list.get(position).getUserNameFromContact();
    }

    textView.setText(myPhone);

    return rowView;
}

/**
 * shows dialog of promotion tools
 */
public void showPromotionPieceDialog(final String fileName,
        final int position) {
    final CharSequence[] items = {
            context.getString(R.string.confirm_play),
            context.getString(R.string.confirm_send),
            context.getString(R.string.options_delete) };

    new AlertDialog.Builder(context).setTitle(R.string.options_title)
            .setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    if (item == 0) {
                        // startPlay(fileName);
                        startPlayExternal(fileName);
                    } else if (item == 1) {
                        sendMail(fileName);
                    } else if (item == 2) {
                        DeleteRecord(fileName, position);
                    }
                }
            }).show();
}

void DeleteRecord(final String fileName, final int position) {
    new AlertDialog.Builder(context)
            .setTitle(R.string.confirm_delete_title)
            .setMessage(R.string.confirm_delete_text)
            .setPositiveButton(R.string.confirm_delete_yes,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int whichButton) {
                            String filepath = FileHelper.getFilePath()
                                    + "/" + Constants.FILE_DIRECTORY;
                            File file = new File(filepath, fileName);

                            if (file.exists()) {
                                file.delete();
                                list.remove(position);
                                notifyDataSetChanged();
                            }

                            filepath = context.getFilesDir()
                                    .getAbsolutePath()
                                    + "/"
                                    + Constants.FILE_DIRECTORY;
                            file = new File(filepath, fileName);

                            if (file.exists()) {
                                file.delete();
                                list.remove(position);
                                notifyDataSetChanged();
                            }
                        }
                    })
            .setNegativeButton(R.string.confirm_delete_no,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int whichButton) {
                        }
                    }).show();
}

void sendMail(String fileName) {
    String filepath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/recordedCalls/" ;
    /*
    String filepath = FileHelper.getFilePath() + "/"
            + Constants.FILE_DIRECTORY;

    */
    File file = new File(filepath, fileName);

    Uri uri = Uri.fromFile(file);
    Intent share = new Intent(Intent.ACTION_SEND);

    share.putExtra(Intent.EXTRA_SUBJECT, "Recording is attached please find !");
    share.putExtra(Intent.EXTRA_TEXT, "hey im sending you recoding of our call ");
    share.setType("audio/*");
    share.putExtra(Intent.EXTRA_STREAM, uri);
    context.startActivity(Intent.createChooser(share, "Share Sound File"));

}

void startPlayExternal(String charSequence) {
    String filepath = Environment.getExternalStorageDirectory().getAbsolutePath();
    File file = new File(filepath, charSequence);
    MediaPlayer mpl=new MediaPlayer();
    //Uri intentUri;

    if (file.exists())

        mpl.setAudioStreamType(AudioManager.STREAM_MUSIC);

        try {
            mpl.setDataSource(Environment.getExternalStorageDirectory().getPath()+"/recordedCalls/"+charSequence);
        } catch (IllegalArgumentException e) {
            Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
        } catch (SecurityException e) {
            Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
        } catch (IllegalStateException e) {
            Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
        } catch (IOException e) {
            e.printStackTrace();
        }

        try {
            mpl.prepare();
        } catch (IllegalStateException e) {
            Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
        } catch (IOException e) {
            Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
        }

        mpl.start();

}

        //intentUri = Uri.parse("file://"+Environment.getExternalStorageDirectory().getPath()+ "/recordedCalls / "+charSequence);

public void removeFromList(int position) {
    list.remove(position);
}

}

champrocks3190 commented 8 years ago

thank you riui88 , for uploading it on github , it will be helpful for my project , great work .