Spaces:
Running
Running
Commit History
-
I need a complete app made from front on including the back end. Here are some codes too: ( package com.example.voiceautoresponder; import android.app.Notification; import android.content.Intent; import android.os.Bundle; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.app.PendingIntent; import androidx.core.app.RemoteInput; public class NotificationResponderService extends NotificationListenerService { private static final String GOOGLE_VOICE_PACKAGE = "com.google.android.apps.googlevoice"; private static final String REPLY_KEYWORD = "Reply"; private static final String AUTO_REPLY_MESSAGE = "Thanks for your message! This is an automated reply."; // <-- EDIT YOUR MESSAGE HERE @Override public void onNotificationPosted(StatusBarNotification sbn) { // Only process notifications from the Google Voice app. if (!sbn.getPackageName().equals(GOOGLE_VOICE_PACKAGE)) { return; } Notification notification = sbn.getNotification(); if (notification == null) { return; } // Avoid replying to notifications for group messages, missed calls, or voicemails. String notificationTitle = notification.extras.getString(Notification.EXTRA_TITLE, "").toLowerCase(); if (notificationTitle.contains(":") || notificationTitle.contains("missed call") || notificationTitle.contains("new voicemail")) { return; } // Find the "Reply" action within the notification. Notification.Action replyAction = findReplyAction(notification); if (replyAction != null) { sendReply(replyAction); } } private Notification.Action findReplyAction(Notification notification) { if (notification.actions == null || notification.actions.length == 0) { return null; } for (Notification.Action action : notification.actions) { if (action.getRemoteInputs() != null) { for (RemoteInput remoteInput : action.getRemoteInputs()) { // Check if the action's label contains "Reply". if (remoteInput.getLabel().toString().equalsIgnoreCase(REPLY_KEYWORD)) { return action; } } } } return null; } private void sendReply(Notification.Action replyAction) { Intent intent = new Intent(); Bundle bundle = new Bundle(); for (RemoteInput remoteInput : replyAction.getRemoteInputs()) { bundle.putCharSequence(remoteInput.getResultKey(), AUTO_REPLY_MESSAGE); } RemoteInput.addResultsToIntent(replyAction.getRemoteInputs(), intent, bundle); try { // Trigger the reply action. replyAction.actionIntent.send(this, 0, intent); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } } } ). Here's another ( <service android:name=".NotificationResponderService" android:label="Voice Auto Responder Service" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" android:exported="true"> <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service> ). Here's another one: ( <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="16dp" tools:context=".MainActivity"> <TextView android:id="@+id/textViewInfo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="To enable the Google Voice auto-responder, you must grant this app Notification Access." android:textSize="18sp" android:layout_centerHorizontal="true" android:layout_above="@id/buttonEnable" android:layout_marginBottom="24dp" android:textAlignment="center"/> <Button android:id="@+id/buttonEnable" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Open Notification Settings" android:layout_centerInParent="true"/> </RelativeLayout> ). Here is another one:( package com.example.voiceautoresponder; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.provider.Settings; import android.widget.Button; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button enableButton = findViewById(R.id.buttonEnable); enableButton.setOnClickListener(v -> { // Open the Notification Access settings screen. Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS); startActivity(intent); }); } } ). That's all of them. Now make a complete app please - Initial Deployment
Verified signatureb55128f -
initial commit
Verified signature23334f1