如何在应用程序卸载时从服务器中删除数据库记录

How can i remove DB record from server at the time of app uninstall

我正在尝试跟踪我的应用程序包,每当用户卸载它时,我想从服务器端删除用户记录,为了实现这个目标,我正在尝试制作一个 worker thread 使用这些 ans 在服务器中发送 post 请求。我知道这类问题被多次问过,我也试过,但我还没有找到任何解决方案。 任何形式的帮助,如外部 link 将不胜感激

  1. Listen Broadcast Before application uninstall

  2. How to clear db when app is uninstalled in android

    Thread PostZReqThread = new Thread() {
            private Handler handler = new Handler();
    
    
                    handler.post(new Runnable() {
                        public void run() {
                            // my Post request ..
                        }
                    });
    

在评论 the link 和另一个堆栈示例的帮助下,我使用广播接收器和一个简单的线程找到了答案。
代码的基本部分如下-
menifeast 收件人代码

 <receiver android:name="install_notifier">
 <intent-filter android:priority="100">
 <action android:name="android.intent.action.DELETE" />
 <action android:name="android.intent.action.PACKAGE_INSTALL" />
 <action android:name="android.intent.action.PACKAGE_ADDED" />
 <action android:name="android.intent.action.PACKAGE_REMOVED" />
 <data android:scheme="package" />
 </intent-filter>
 </receiver>

//class接收广播

 public class Unintsall_notifier extends BroadcastReceiver {
 @Override
 public void onReceive(Context context, Intent intent) {
    Log.e("TAG","GET_INTENT_HIT...");
    }
 }