While asking permission, use if then logic
If the sdk version greater than 33
Ask record audio
Else
Ask all the 3 permissions
And store the file in ASD
While asking permission, use if then logic
If the sdk version greater than 33
Ask record audio
Else
Ask all the 3 permissions
And store the file in ASD
ASD mean??i am new.
Please can you give me block example or Aia file?thanks
go through with this thread and Will come to know what should be done
I don’t want waste more time..i want hire one developer who can make this for Android 13..suggest me one mit app developer
I now joined your 2 threads
Please do not start a new thread with the same question,
You forgot to follow my suggestions
Taifun
Sometimes AI gives misleading information
See again
Taifun
this problem solved but it not working in android
version 13
You did not fix the issues from your latest screenshot
Taifun
leave this screenshot and tell me it possible or not.can i make background recorder for android 13?
My guess was, that it will not work for newer Android versions, but Gemini had another opinion. . See again Not working for background soundRecorder - #5 by Taifun
You previously said, it worked? Which Android version was that? It would help to fix the errors in the screenshot...
Taifun
It looks like ChatGPT is correct
Taifun
have not any way?
how can working whatsapp or others calling app?
Use your solution on older devices
Say thank you to Google for protecting us from the evil
Where exactly do these apps record audio in the background?
It still might be possible for system apps
For further questions don't hesitate to ask AI for help, I currently have nothing more to add to the discussion
Taifun
okay i am leaving mit app..
I now asked ChatGPT for you
I would like to write an Android app for my Android14 device, which will allow me to record audio in the background while the app is not open. Can you help me with some code snippets for Java?
Please find below the answer.
You could take the answer and write your own extension to provide a solution for App Inventor
Taifun
Sure! Creating an Android app that records audio in the background on Android 14 (API level 34) requires careful handling of permissions and foreground services due to stricter background task limitations. Below is a basic setup using Java that:
AndroidManifest.xml
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Add your service:
<application ...>
<service
android:name=".AudioRecordService"
android:foregroundServiceType="microphone"
android:exported="false" />
</application>
public class MainActivity extends AppCompatActivity {
private static final int PERMISSION_CODE = 200;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (!checkPermissions()) {
requestPermissions();
}
findViewById(R.id.startButton).setOnClickListener(v -> {
Intent intent = new Intent(this, AudioRecordService.class);
ContextCompat.startForegroundService(this, intent);
});
}
private boolean checkPermissions() {
return ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
}
private void requestPermissions() {
ActivityCompat.requestPermissions(this, new String[]{
Manifest.permission.RECORD_AUDIO
}, PERMISSION_CODE);
}
}
public class AudioRecordService extends Service {
private MediaRecorder recorder;
private File audioFile;
@Override
public void onCreate() {
super.onCreate();
startForeground(1, createNotification());
startRecording();
}
private Notification createNotification() {
NotificationChannel channel = new NotificationChannel(
"record_channel",
"Audio Recorder",
NotificationManager.IMPORTANCE_LOW
);
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
return new NotificationCompat.Builder(this, "record_channel")
.setContentTitle("Recording audio")
.setSmallIcon(android.R.drawable.ic_btn_speak_now)
.build();
}
private void startRecording() {
try {
audioFile = new File(getExternalFilesDir(null), "recorded_audio.mp3");
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setOutputFile(audioFile.getAbsolutePath());
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.prepare();
recorder.start();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
if (recorder != null) {
recorder.stop();
recorder.release();
}
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
<Button
android:id="@+id/startButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start Recording" />
Would you like to add stop recording or save/share functionality too?
hola como estas yo no sabe
I cannot understanded custom code..i am
a php,laravel,vuejs developer