Android 我无法从服务器接收任何通知

Android 我无法从服务器接收任何通知,android,json,android-notifications,android-broadcastreceiver,Android,Json,Android Notifications,Android Broadcastreceiver,这是我从服务器接收数据的类:它不显示通知 但是如果我将sendBroadcast(intent)和intent从try-and-catch块中取出并使msg=null;它显示通知,但带有空消息 我需要你的帮助 package com.example.hussienalrubaye.myapplication; import android.app.IntentService; import android.content.Intent; import android.support.anno

这是我从服务器接收数据的类:它不显示通知 但是如果我将sendBroadcast(intent)和intent从try-and-catch块中取出并使msg=null;它显示通知,但带有空消息 我需要你的帮助

package com.example.hussienalrubaye.myapplication;


import android.app.IntentService;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;



public class Sev_data extends IntentService {
    public static boolean ServiceIsRun = false;
    public Sev_data() {
        super("MyWebRequestService");
    }
    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        while (ServiceIsRun) {
            int id_s=0;//هنا رقم اخر رسلة وصلة التطبيق
            String url0 = "http://localhost/sendapp.php?co>"+id_s;//رايط ملف الداتة من السيرفر
            String  msg;
            try {
                URL url = new URL(url0);
                HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
                InputStream in = new BufferedInputStream(urlConnection.getInputStream());
                msg = Stream2String(in);
                in.close();
                JSONObject jsonRootObject = new JSONObject(msg);
                JSONArray jsonArray = jsonRootObject.optJSONArray("date");
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);
                    String id= jsonObject.optString("id");
                    String title = jsonObject.optString("title");
                    String mess = jsonObject.optString("description");
                    ///// هنا نهاية الموضوع دي اخر رسلة علي السيرفر
                }
                // creat new intent
                intent = new Intent();
                //set the action that will receive our broadcast
                intent.setAction("com.example.Broadcast");
                // add data to the bundle
                intent.putExtra("msg", msg);
                // send the data to broadcast
                sendBroadcast(intent);
                //delay for 50000ms
            } catch (Exception e) {
            }
            try{
                Thread.sleep(20000);
            }catch (Exception ex){}
        }
    }
    String date="";
    public String Stream2String(InputStream inputStream) {
        BufferedReader bureader=new BufferedReader( new InputStreamReader(inputStream));
        String line ;
        String Text="";
        try{
            while((line=bureader.readLine())!=null) {
                Text+=line;
            }
            inputStream.close();
        }catch (Exception ex){}
        return Text;
    }
}
我添加了所有AndroidManifest权限,所有的事情都做得很好,但它没有显示通知
我想知道。从服务器获取数据的cod是否为真http://localhost/senda........?服务器在哪里运行?
catch(异常e){
您什么也没做!甚至没有打印stacktrace。您可以在此处向发送广播,并使用不同的消息通知用户。您有两个这样的未实现的捕获块。做点什么!
但它不显示通知
?不清楚谁应该显示通知。什么时候?没有代码。对不起,我忘记添加了ceiver类,但我想知道。从服务器获取数据的cod是否为真您的代码未在android studio中运行。
localhost
将是android设备,而不是运行web服务器的计算机
package com.example.doblist.mydobservice;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class MyReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // get the bundles in the message
        final Bundle bundle = intent.getExtras();
        // check the action equal to the action we fire in broadcast,
        if   (   intent.getAction().equalsIgnoreCase("com.example.Broadcast"))
        //read the data from the intent
        { NewMessageNotification notfilyme= new NewMessageNotification();
            notfilyme.notify(context,bundle.getString("msg"),223);}
        //  Toast.makeText(context,bundle.getString("msg"),Toast.LENGTH_LONG).show();
    }
}