祈祷时间的android(اوقاتشرعی)时间、android

2023-09-03 21:28:36 作者:愚爱

我试图在栈此链接:

How在穆斯林祈祷时间的计算方法在Android应用程序?

和本的教程,并解析响应JSON的,但它不T给出正确的时间。我想我已经在请求URL填充GMT一部分问题。我的纬度位置和纬度。

链接例如:http://api.xhanch.com/islamic-get-prayer-time.php?lng=50.0000&lat=36.2667&yy=2015&mm=9&gmt=?????????&m=json

我有什么写在格林尼治标准​​时间前在请求URL?

感谢您

更新:

此链接是我的解决方案和穆斯林祈祷时间最好的API。

这是我的code:

 公共无效PrayerSendReq(){

    长unixTime = System.currentTimeMillis的()/ 1000L;

    字符串urlStr =htt​​p://api.aladhan.com/timings/+ unixTime +?纬度= 36.2687700&放大器;经度= 50.0041000&放大器; timezonestring =亚洲/德黑兰和放大器;方法= 7;


    Log.d(祈祷URL:urlStr);
    //排球请求队列
    请求队列排队= Volley.newRequestQueue(本);

    JsonObjectRequest JOReq =新JsonObjectRequest(Request.Method.GET,urlStr,(字符串)空,
            新Response.Listener<的JSONObject>(){
                @覆盖
                公共无效onResponse(JSONObject的响应){

                    JSONObject的JO =响应;
                    Log.d(祈祷resJson,response.toString());


                    JSONObject的resultJO =新的JSONObject();

                    尝试 {
                        JSONObject的项目= JO.getJSONObject(数据);
                        resultJO = items.getJSONObject(定时);
                    }赶上(JSONException E){
                        e.printStackTrace();
                    }


                    Log.d(最后JO:resultJO.toString());

                    如果(resultJO!= NULL){


                        尝试 {
                            黎明= resultJO.getString(黎明);
                            editor.putString(黎明,晨);

                            日出= resultJO.getString(日出);
                            editor.putString(日出,日出);

                            晌礼= resultJO.getString(Dhuhr);
                            editor.putString(晌礼,晌礼);

                            azanMaghrib = resultJO.getString(昏礼);
                            editor.putString(azanMaghrib,azanMaghrib);

                            日落= resultJO.getString(日落);
                            editor.putString(日落,日落);

                            editor.putString(存在,某事);

                            editor.apply();


                            azanMaghribTv.setText(将String.valueOf(prefs.getString(azanMaghrib,azanMaghrib)));

                            azanSobTv.setText(将String.valueOf(prefs.getString(黎明,晨)));

                            sunriseTv.setText(将String.valueOf(prefs.getString(日出,日出)));

                            azanZohrTv.setText(将String.valueOf(prefs.getString(晌礼,晌礼)));

                            sunsetTv.setText(将String.valueOf(prefs.getString(日落,日落)));


                        }赶上(JSONException E){
                            e.printStackTrace();
                        }
                    }


                }
            },新Response.ErrorListener(){
        @覆盖
        公共无效onErrorResponse(VolleyError错误){

        }
    });

    //它添加到请求队列
    queue.add(JOReq);

}
 

和内部活动的OnCreate:

  azanSobTv =(TextView中)findViewById(R.id.pray_ac_sob);
    sunriseTv =(TextView中)findViewById(R.id.pray_ac_toloo);
    azanZohrTv =(TextView中)findViewById(R.id.pray_ac_zohr);
    azanMaghribTv =(TextView中)findViewById(R.id.pray_ac_maghrib);
    sunsetTv =(TextView中)findViewById(R.id.pray_ac_sunset);



    azanSobTv.setTypeface(Fonts.TrafficB);
    sunriseTv.setTypeface(Fonts.TrafficB);
    azanZohrTv.setTypeface(Fonts.TrafficB);
    azanMaghribTv.setTypeface(Fonts.TrafficB);
    sunsetTv.setTypeface(Fonts.TrafficB);

    PrayerSendReq();

    如果(prefs.getString(存在,NULL)!= NULL){

        azanMaghribTv.setText(将String.valueOf(prefs.getString(azanMaghrib,azanMaghrib)));

        azanSobTv.setText(将String.valueOf(prefs.getString(黎明,晨)));

        sunriseTv.setText(将String.valueOf(prefs.getString(日出,日出)));

        azanZohrTv.setText(将String.valueOf(prefs.getString(晌礼,晌礼)));

        sunsetTv.setText(将String.valueOf(prefs.getString(日落,日落)));
    }
 

解决方案

您需要输入该位置的时区。 请参阅 http://unattended.sourceforge.net/timezones.php 的时区的列表。

例如,如果你想(太平洋时间),输入4。

I tried this link in stack :

How is the Muslim Prayer time is calculated in an android application?

and this tutorial and parsed the response Json but it doesn't give correct times. I think I have problem in filling gmt part in request url. I have latitude and longitude of the location.

link example : http://api.xhanch.com/islamic-get-prayer-time.php?lng=50.0000&lat=36.2667&yy=2015&mm=9&gmt=?????????&m=json

What do I have to write in front of gmt in request url?

Thank you

UPDATE :

this link was my solution and the best API for muslim prayer times.

this is my code :

public void PrayerSendReq() {

    long unixTime = System.currentTimeMillis() / 1000L;

    String urlStr = "http://api.aladhan.com/timings/" + unixTime + "?latitude=36.2687700&longitude=50.0041000&timezonestring=Asia/Tehran&method=7";


    Log.d("Prayer url : ", urlStr);
    // Volley request queue
    RequestQueue queue = Volley.newRequestQueue(this);

    JsonObjectRequest JOReq = new JsonObjectRequest(Request.Method.GET, urlStr, (String) null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {

                    JSONObject JO = response;
                    Log.d("prayer resJson", response.toString());


                    JSONObject resultJO = new JSONObject();

                    try {
                        JSONObject items = JO.getJSONObject("data");
                        resultJO = items.getJSONObject("timings");
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }


                    Log.d("Last JO : ", resultJO.toString());

                    if (resultJO != null) {


                        try {
                            fajr = resultJO.getString("Fajr");
                            editor.putString("fajr", fajr);

                            sunrise = resultJO.getString("Sunrise");
                            editor.putString("sunrise", sunrise);

                            zuhr = resultJO.getString("Dhuhr");
                            editor.putString("zuhr", zuhr);

                            azanMaghrib = resultJO.getString("Maghrib");
                            editor.putString("azanMaghrib", azanMaghrib);

                            sunset = resultJO.getString("Sunset");
                            editor.putString("sunset", sunset);

                            editor.putString("exists", "sth");

                            editor.apply();


                            azanMaghribTv.setText(String.valueOf(prefs.getString("azanMaghrib", azanMaghrib)));

                            azanSobTv.setText(String.valueOf(prefs.getString("fajr", fajr)));

                            sunriseTv.setText(String.valueOf(prefs.getString("sunrise", sunrise)));

                            azanZohrTv.setText(String.valueOf(prefs.getString("zuhr", zuhr)));

                            sunsetTv.setText(String.valueOf(prefs.getString("sunset", sunset)));


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }


                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {

        }
    });

    // add it to the RequestQueue
    queue.add(JOReq);

}

and inside activity oncreate:

    azanSobTv = (TextView) findViewById(R.id.pray_ac_sob);
    sunriseTv = (TextView) findViewById(R.id.pray_ac_toloo);
    azanZohrTv = (TextView) findViewById(R.id.pray_ac_zohr);
    azanMaghribTv = (TextView) findViewById(R.id.pray_ac_maghrib);
    sunsetTv = (TextView) findViewById(R.id.pray_ac_sunset);



    azanSobTv.setTypeface(Fonts.TrafficB);
    sunriseTv.setTypeface(Fonts.TrafficB);
    azanZohrTv.setTypeface(Fonts.TrafficB);
    azanMaghribTv.setTypeface(Fonts.TrafficB);
    sunsetTv.setTypeface(Fonts.TrafficB);

    PrayerSendReq();

    if (prefs.getString("exists", null) != null) {

        azanMaghribTv.setText(String.valueOf(prefs.getString("azanMaghrib", azanMaghrib)));

        azanSobTv.setText(String.valueOf(prefs.getString("fajr", fajr)));

        sunriseTv.setText(String.valueOf(prefs.getString("sunrise", sunrise)));

        azanZohrTv.setText(String.valueOf(prefs.getString("zuhr", zuhr)));

        sunsetTv.setText(String.valueOf(prefs.getString("sunset", sunset)));
    }

解决方案

You need to enter the timezone of the location. Refer http://unattended.sourceforge.net/timezones.php for list of timezones.

For example, if you want Pacific Time, enter 4.