Error getting on parsing json data with getting positions in listview
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
This is my MainClass where I am showing the Listview as a Surah List
package com.example.prayertimes.timetoperformprayers;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.ArrayAdapter;
import com.example.prayertimes.timetoperformingprayers.R;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SharedSurahPref;
import com.example.prayertimes.timetoperformprayers.QuranData.Surah;
import java.util.ArrayList;
import java.util.List;
import android.widget.TextView;
public class QuranVersions extends AppCompatActivity
List<String> SurahList;
ListView SurahListName;
TextView Ayah;
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
private void prepareDate()
SurahList = new ArrayList<>();
SurahList.add("1 Surah Al-Fatihah");
SurahList.add("2 Surah Al-Baqara");
SurahList.add("3 Surah Al-i'Imran");
SurahList.add("4 Surah An-Nisaa");
SurahList.add("5 Surah Al-Maidah");
SurahList.add("6 Surah Al-An'am");
SurahList.add("7 Surah Al-A'raf");
SurahList.add("8 Surah Al-Anfal");
SurahList.add("9 Surah At-Tauba");
SurahList.add("10 Surah Yunus");
SurahList.add("11 Surah Hud");
SurahList.add("12 Surah Yusuf");
SurahList.add("13 Surah Ar-Ra'd");
SurahList.add("14 Surah Ibrahim");
SurahList.add("15 Surah Al-Hijr");
SurahList.add("16 Surah An-Nahl");
SurahList.add("17 Surah Al-Israa");
SurahList.add("18 Surah Al-Kahf");
SurahList.add("19 Surah Maryam");
SurahList.add("20 Surah Ta-ha");
SurahList.add("21 Surah Al-Anbiyaa");
SurahList.add("22 Surah Al-Hajj");
SurahList.add("23 Surah Al-Muminun");
SurahList.add("24 Surah An-Nur");
SurahList.add("25 Surah Al-Furqan");
SurahList.add("26 Surah Ash-Shu'araa");
SurahList.add("27 Surah An-Naml");
SurahList.add("28 Surah Al-Qasas");
SurahList.add("29 Surah Al-Ankabut");
SurahList.add("30 Surah Ar-Rum");
SurahList.add("31 Surah Luqman");
SurahList.add("32 Surah As-Sajda");
SurahList.add("33 Surah Al-Ahzab");
SurahList.add("34 Surah Saba");
SurahList.add("35 Surah Fatir");
SurahList.add("36 Surah Ya-Sin");
SurahList.add("37 Surah As-Saffat");
SurahList.add("38 Surah Sad");
SurahList.add("39 Surah Az-Zumar");
SurahList.add("40 Surah Al-Mu'min");
SurahList.add("41 Surah Ha-Mim");
SurahList.add("42 Surah Ash-Shura");
SurahList.add("43 Surah Az-Zukhruf");
SurahList.add("44 Surah Ad-Dukhan");
SurahList.add("45 Surah Al-Jathiya");
SurahList.add("46 Surah Al-Ahqaf");
SurahList.add("47 Surah Muhammad");
SurahList.add("48 Surah Al-Fat-h");
SurahList.add("49 Surah Al-Hujurat");
SurahList.add("50 Surah Qaf");
SurahList.add("51 Surah Az-Zariyat");
SurahList.add("52 Surah At-Tur");
SurahList.add("53 Surah An-Najm");
SurahList.add("54 Surah Al-Qamar");
SurahList.add("55 Surah Ar-Rahman");
SurahList.add("56 Surah Al-Waqi'a");
SurahList.add("57 Surah Al-Hadid");
SurahList.add("58 Surah Al-Mujadila");
SurahList.add("59 Surah Al-Hashr");
SurahList.add("60 Surah Al-Mumtahana");
SurahList.add("61 Surah As-Saff");
SurahList.add("62 Surah Al-Jumu'a");
SurahList.add("63 Surah Al-Munafiqun");
SurahList.add("64 Surah At-Tagabun");
SurahList.add("65 Surah At-Talaq");
SurahList.add("66 Surah At-Tahrim");
SurahList.add("67 Surah Al-Mulk");
SurahList.add("68 Surah Al-Qalam");
SurahList.add("69 Surah Al-Haqqa");
SurahList.add("70 Surah Al-Ma'arij");
SurahList.add("71 Surah Nuh");
SurahList.add("72 Surah Al-Jinn");
SurahList.add("73 Surah Al-Muzzammil");
SurahList.add("74 Surah Al-Muddathth");
SurahList.add("75 Surah Al-Qiyamat");
SurahList.add("76 Surah Ad-Dahr");
SurahList.add("77 Surah Al-Mursalat");
SurahList.add("78 Surah An-Nabaa");
SurahList.add("79 Surah An-Nazi'at");
SurahList.add("80 Surah Abasa");
SurahList.add("81 Surah At-Takwir");
SurahList.add("82 Surah Al-Infitar");
SurahList.add("83 Surah Al-Mutaffifin");
SurahList.add("84 Surah Al-Inshiqaq");
SurahList.add("85 Surah Al-Buruj");
SurahList.add("86 Surah At-Tariq");
SurahList.add("87 Surah Al-A'la");
SurahList.add("88 Surah Al-Gashiya");
SurahList.add("89 Surah Al-Fajr");
SurahList.add("90 Surah Al-Balad");
SurahList.add("91 Surah Ash-Shams");
SurahList.add("92 Surah Al-Lail");
SurahList.add("93 Surah Adh-Dhuha");
SurahList.add("94 Surah Al-Sharh");
SurahList.add("95 Surah At-Tin");
SurahList.add("96 Surah Al-Alaq");
SurahList.add("97 Surah Al-Qadr");
SurahList.add("98 Surah Al-Baiyina");
SurahList.add("99 Surah Al-Zalzalah");
SurahList.add("100 Surah Al-Adiyat");
SurahList.add("101 Surah Al-Qari'a");
SurahList.add("102 Surah At-Takathur");
SurahList.add("103 Surah Al-Asr");
SurahList.add("104 Surah Al-Humaza");
SurahList.add("105 Surah Al-Fil");
SurahList.add("106 Surah Quraish");
SurahList.add("107 Surah Al-Ma'un");
SurahList.add("108 Surah Al-Kauthar");
SurahList.add("109 Surah Al-Kafirun");
SurahList.add("110 Surah An-Nasr");
SurahList.add("111 Surah Al-Lahab");
SurahList.add("112 Surah Al-Ikhlas");
SurahList.add("113 Surah Al-Falaq");
SurahList.add("114 Surah Al-Nas");
// Read the company.json file and convert it to a java object.
This is my XML file of this class
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp"
tools:context="com.example.prayertimes.timetoperformprayers.QuranVersions">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/ayah"
android:text=""/>
<ListView
android:id="@+id/quranAyahList"
android:layout_gravity="center"
android:gravity="center"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
This is my Surah file where I am parsing json data
Surah.Java
package com.example.prayertimes.timetoperformprayers.QuranData;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.example.prayertimes.timetoperformingprayers.R;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SharedSurahPref;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SurahResponse;
import com.google.gson.Gson;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class Surah extends AppCompatActivity
ListView AyatDetail;
List<String> ayatLDetail;
TextView totalAyat, surahNum, surahName;
int selectedSurrahIndex = 0;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_surah);
selectedSurrahIndex = getIntent().getIntExtra("index",0);
generateSurahData(selectedSurrahIndex);
setUpUiView();
final ArrayAdapter<String> ayatList = new ArrayAdapter<String>(Surah.this, android.R.layout.simple_list_item_1, ayatLDetail);
AyatDetail.setAdapter(ayatList);
private void setUpUiView()
totalAyat = findViewById(R.id.totalAyah);
surahNum = findViewById(R.id.surahNo);
surahName = findViewById(R.id.surahName);
AyatDetail = (ListView) findViewById(R.id.AyatDetail);
private void generateSurahData(int surrahIndex)
if(!SharedSurahPref.allSurah.containsKey(surrahIndex))
InputStream inputStream = getResources().openRawResource(SharedSurahPref.SurrahNames.get(surrahIndex));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int ctr;
try
ctr = inputStream.read();
while (ctr != -1)
byteArrayOutputStream.write(ctr);
ctr = inputStream.read();
inputStream.close();
catch (IOException e)
e.printStackTrace();
Log.v("Text Data", byteArrayOutputStream.toString());
try
// Parse the data into json object to get original data in form of json.
JSONObject jObject = new JSONObject(byteArrayOutputStream.toString());
SurahResponse model = new Gson().fromJson(jObject.toString(), SurahResponse.class);
SharedSurahPref.allSurah.put(surrahIndex, model);
if (SharedSurahPref.allSurah.size() > surrahIndex)
totalAyat.setText(SharedSurahPref.allSurah.get(surrahIndex).getTotalAyah());
surahNum.setText(SharedSurahPref.allSurah.get(surrahIndex).getSurahNo()+"");
totalAyat.setText(SharedSurahPref.allSurah.get(surrahIndex).getTotalAyah()+"");
ayatLDetail.add(SharedSurahPref.detailHashMap.get(surrahIndex).getArbi());
catch (Exception e)
e.printStackTrace();
This is the XML file of Surah.java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context="com.example.prayertimes.timetoperformprayers.QuranData.Surah">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/totalAyah"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/surahNo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/surahName"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ayatNum"/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/AyatDetail"/>
</LinearLayout>
This is the SharefSurahPref.class where all the json files are parsing to the surah activity
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import android.view.View;
import com.example.prayertimes.timetoperformingprayers.R;
import com.google.android.gms.flags.impl.SharedPreferencesFactory;
import java.util.ArrayList;
import java.util.HashMap;
public class SharedSurahPref extends SharedPreferencesFactory
public static ArrayList<Integer> SurrahNames = new ArrayList<>();
public static HashMap<Integer,SurahResponse> allSurah = new HashMap<>();
public static HashMap<String, AyatDetail> detailHashMap = new HashMap();
SharedSurahPref()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
This is the Ayat Verses getter and setters
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class AyatDetail extends SurahResponse
@SerializedName("ayet_no")
@Expose
private Integer ayetNo;
@SerializedName("arbi")
@Expose
private String arbi;
@SerializedName("Urdu")
@Expose
private String urdu;
@SerializedName("English")
@Expose
private String english;
public Integer getAyetNo()
return ayetNo;
public void setAyetNo(Integer ayetNo)
this.ayetNo = ayetNo;
public String getArbi()
return arbi;
public void setArbi(String arbi)
this.arbi = arbi;
public String getUrdu()
return urdu;
public void setUrdu(String urdu)
this.urdu = urdu;
public String getEnglish()
return english;
public void setEnglish(String english)
this.english = english;
This is the surah no and surah name getter setter class
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SurahResponse
@SerializedName("surah_no")
@Expose
private Integer surahNo;
@SerializedName("total_ayah")
@Expose
private Integer totalAyah;
@SerializedName("name")
@Expose
private String name;
@SerializedName("detail")
@Expose
private List<AyatDetail> detail = null;
public Integer getSurahNo()
return surahNo;
public void setSurahNo(Integer surahNo)
this.surahNo = surahNo;
public Integer getTotalAyah()
return totalAyah;
public void setTotalAyah(Integer totalAyah)
this.totalAyah = totalAyah;
public String getName()
return name;
public void setName(String name)
this.name = name;
public List<AyatDetail> getDetail()
return detail;
public void setDetail(List<AyatDetail> detail)
this.detail = detail;
When i click on the first index in listview the logcat gives an error of included below
Process: com.example.osamasaleem.prayertimes, PID: 31057
android.content.ActivityNotFoundException: Unable to find explicit activity class com.example.osamasaleem.prayertimes/com.example.prayertimes.timetoperformprayers.QuranData.Surah; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1895)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1589)
at android.app.Activity.startActivityForResult(Activity.java:4234)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:4192)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at android.app.Activity.startActivity(Activity.java:4535)
at android.app.Activity.startActivity(Activity.java:4503)
at com.example.prayertimes.timetoperformprayers.QuranVersions$1.onItemClick(QuranVersions.java:42)
at android.widget.AdapterView.performItemClick(AdapterView.java:315)
at android.widget.AbsListView.performItemClick(AbsListView.java:1210)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3349)
at android.widget.AbsListView$4.run(AbsListView.java:4410)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6339)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
This is my 41 line number
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
}
How can I fix this Logcat error?
java sharedpreferences
add a comment |
This is my MainClass where I am showing the Listview as a Surah List
package com.example.prayertimes.timetoperformprayers;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.ArrayAdapter;
import com.example.prayertimes.timetoperformingprayers.R;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SharedSurahPref;
import com.example.prayertimes.timetoperformprayers.QuranData.Surah;
import java.util.ArrayList;
import java.util.List;
import android.widget.TextView;
public class QuranVersions extends AppCompatActivity
List<String> SurahList;
ListView SurahListName;
TextView Ayah;
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
private void prepareDate()
SurahList = new ArrayList<>();
SurahList.add("1 Surah Al-Fatihah");
SurahList.add("2 Surah Al-Baqara");
SurahList.add("3 Surah Al-i'Imran");
SurahList.add("4 Surah An-Nisaa");
SurahList.add("5 Surah Al-Maidah");
SurahList.add("6 Surah Al-An'am");
SurahList.add("7 Surah Al-A'raf");
SurahList.add("8 Surah Al-Anfal");
SurahList.add("9 Surah At-Tauba");
SurahList.add("10 Surah Yunus");
SurahList.add("11 Surah Hud");
SurahList.add("12 Surah Yusuf");
SurahList.add("13 Surah Ar-Ra'd");
SurahList.add("14 Surah Ibrahim");
SurahList.add("15 Surah Al-Hijr");
SurahList.add("16 Surah An-Nahl");
SurahList.add("17 Surah Al-Israa");
SurahList.add("18 Surah Al-Kahf");
SurahList.add("19 Surah Maryam");
SurahList.add("20 Surah Ta-ha");
SurahList.add("21 Surah Al-Anbiyaa");
SurahList.add("22 Surah Al-Hajj");
SurahList.add("23 Surah Al-Muminun");
SurahList.add("24 Surah An-Nur");
SurahList.add("25 Surah Al-Furqan");
SurahList.add("26 Surah Ash-Shu'araa");
SurahList.add("27 Surah An-Naml");
SurahList.add("28 Surah Al-Qasas");
SurahList.add("29 Surah Al-Ankabut");
SurahList.add("30 Surah Ar-Rum");
SurahList.add("31 Surah Luqman");
SurahList.add("32 Surah As-Sajda");
SurahList.add("33 Surah Al-Ahzab");
SurahList.add("34 Surah Saba");
SurahList.add("35 Surah Fatir");
SurahList.add("36 Surah Ya-Sin");
SurahList.add("37 Surah As-Saffat");
SurahList.add("38 Surah Sad");
SurahList.add("39 Surah Az-Zumar");
SurahList.add("40 Surah Al-Mu'min");
SurahList.add("41 Surah Ha-Mim");
SurahList.add("42 Surah Ash-Shura");
SurahList.add("43 Surah Az-Zukhruf");
SurahList.add("44 Surah Ad-Dukhan");
SurahList.add("45 Surah Al-Jathiya");
SurahList.add("46 Surah Al-Ahqaf");
SurahList.add("47 Surah Muhammad");
SurahList.add("48 Surah Al-Fat-h");
SurahList.add("49 Surah Al-Hujurat");
SurahList.add("50 Surah Qaf");
SurahList.add("51 Surah Az-Zariyat");
SurahList.add("52 Surah At-Tur");
SurahList.add("53 Surah An-Najm");
SurahList.add("54 Surah Al-Qamar");
SurahList.add("55 Surah Ar-Rahman");
SurahList.add("56 Surah Al-Waqi'a");
SurahList.add("57 Surah Al-Hadid");
SurahList.add("58 Surah Al-Mujadila");
SurahList.add("59 Surah Al-Hashr");
SurahList.add("60 Surah Al-Mumtahana");
SurahList.add("61 Surah As-Saff");
SurahList.add("62 Surah Al-Jumu'a");
SurahList.add("63 Surah Al-Munafiqun");
SurahList.add("64 Surah At-Tagabun");
SurahList.add("65 Surah At-Talaq");
SurahList.add("66 Surah At-Tahrim");
SurahList.add("67 Surah Al-Mulk");
SurahList.add("68 Surah Al-Qalam");
SurahList.add("69 Surah Al-Haqqa");
SurahList.add("70 Surah Al-Ma'arij");
SurahList.add("71 Surah Nuh");
SurahList.add("72 Surah Al-Jinn");
SurahList.add("73 Surah Al-Muzzammil");
SurahList.add("74 Surah Al-Muddathth");
SurahList.add("75 Surah Al-Qiyamat");
SurahList.add("76 Surah Ad-Dahr");
SurahList.add("77 Surah Al-Mursalat");
SurahList.add("78 Surah An-Nabaa");
SurahList.add("79 Surah An-Nazi'at");
SurahList.add("80 Surah Abasa");
SurahList.add("81 Surah At-Takwir");
SurahList.add("82 Surah Al-Infitar");
SurahList.add("83 Surah Al-Mutaffifin");
SurahList.add("84 Surah Al-Inshiqaq");
SurahList.add("85 Surah Al-Buruj");
SurahList.add("86 Surah At-Tariq");
SurahList.add("87 Surah Al-A'la");
SurahList.add("88 Surah Al-Gashiya");
SurahList.add("89 Surah Al-Fajr");
SurahList.add("90 Surah Al-Balad");
SurahList.add("91 Surah Ash-Shams");
SurahList.add("92 Surah Al-Lail");
SurahList.add("93 Surah Adh-Dhuha");
SurahList.add("94 Surah Al-Sharh");
SurahList.add("95 Surah At-Tin");
SurahList.add("96 Surah Al-Alaq");
SurahList.add("97 Surah Al-Qadr");
SurahList.add("98 Surah Al-Baiyina");
SurahList.add("99 Surah Al-Zalzalah");
SurahList.add("100 Surah Al-Adiyat");
SurahList.add("101 Surah Al-Qari'a");
SurahList.add("102 Surah At-Takathur");
SurahList.add("103 Surah Al-Asr");
SurahList.add("104 Surah Al-Humaza");
SurahList.add("105 Surah Al-Fil");
SurahList.add("106 Surah Quraish");
SurahList.add("107 Surah Al-Ma'un");
SurahList.add("108 Surah Al-Kauthar");
SurahList.add("109 Surah Al-Kafirun");
SurahList.add("110 Surah An-Nasr");
SurahList.add("111 Surah Al-Lahab");
SurahList.add("112 Surah Al-Ikhlas");
SurahList.add("113 Surah Al-Falaq");
SurahList.add("114 Surah Al-Nas");
// Read the company.json file and convert it to a java object.
This is my XML file of this class
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp"
tools:context="com.example.prayertimes.timetoperformprayers.QuranVersions">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/ayah"
android:text=""/>
<ListView
android:id="@+id/quranAyahList"
android:layout_gravity="center"
android:gravity="center"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
This is my Surah file where I am parsing json data
Surah.Java
package com.example.prayertimes.timetoperformprayers.QuranData;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.example.prayertimes.timetoperformingprayers.R;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SharedSurahPref;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SurahResponse;
import com.google.gson.Gson;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class Surah extends AppCompatActivity
ListView AyatDetail;
List<String> ayatLDetail;
TextView totalAyat, surahNum, surahName;
int selectedSurrahIndex = 0;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_surah);
selectedSurrahIndex = getIntent().getIntExtra("index",0);
generateSurahData(selectedSurrahIndex);
setUpUiView();
final ArrayAdapter<String> ayatList = new ArrayAdapter<String>(Surah.this, android.R.layout.simple_list_item_1, ayatLDetail);
AyatDetail.setAdapter(ayatList);
private void setUpUiView()
totalAyat = findViewById(R.id.totalAyah);
surahNum = findViewById(R.id.surahNo);
surahName = findViewById(R.id.surahName);
AyatDetail = (ListView) findViewById(R.id.AyatDetail);
private void generateSurahData(int surrahIndex)
if(!SharedSurahPref.allSurah.containsKey(surrahIndex))
InputStream inputStream = getResources().openRawResource(SharedSurahPref.SurrahNames.get(surrahIndex));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int ctr;
try
ctr = inputStream.read();
while (ctr != -1)
byteArrayOutputStream.write(ctr);
ctr = inputStream.read();
inputStream.close();
catch (IOException e)
e.printStackTrace();
Log.v("Text Data", byteArrayOutputStream.toString());
try
// Parse the data into json object to get original data in form of json.
JSONObject jObject = new JSONObject(byteArrayOutputStream.toString());
SurahResponse model = new Gson().fromJson(jObject.toString(), SurahResponse.class);
SharedSurahPref.allSurah.put(surrahIndex, model);
if (SharedSurahPref.allSurah.size() > surrahIndex)
totalAyat.setText(SharedSurahPref.allSurah.get(surrahIndex).getTotalAyah());
surahNum.setText(SharedSurahPref.allSurah.get(surrahIndex).getSurahNo()+"");
totalAyat.setText(SharedSurahPref.allSurah.get(surrahIndex).getTotalAyah()+"");
ayatLDetail.add(SharedSurahPref.detailHashMap.get(surrahIndex).getArbi());
catch (Exception e)
e.printStackTrace();
This is the XML file of Surah.java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context="com.example.prayertimes.timetoperformprayers.QuranData.Surah">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/totalAyah"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/surahNo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/surahName"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ayatNum"/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/AyatDetail"/>
</LinearLayout>
This is the SharefSurahPref.class where all the json files are parsing to the surah activity
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import android.view.View;
import com.example.prayertimes.timetoperformingprayers.R;
import com.google.android.gms.flags.impl.SharedPreferencesFactory;
import java.util.ArrayList;
import java.util.HashMap;
public class SharedSurahPref extends SharedPreferencesFactory
public static ArrayList<Integer> SurrahNames = new ArrayList<>();
public static HashMap<Integer,SurahResponse> allSurah = new HashMap<>();
public static HashMap<String, AyatDetail> detailHashMap = new HashMap();
SharedSurahPref()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
This is the Ayat Verses getter and setters
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class AyatDetail extends SurahResponse
@SerializedName("ayet_no")
@Expose
private Integer ayetNo;
@SerializedName("arbi")
@Expose
private String arbi;
@SerializedName("Urdu")
@Expose
private String urdu;
@SerializedName("English")
@Expose
private String english;
public Integer getAyetNo()
return ayetNo;
public void setAyetNo(Integer ayetNo)
this.ayetNo = ayetNo;
public String getArbi()
return arbi;
public void setArbi(String arbi)
this.arbi = arbi;
public String getUrdu()
return urdu;
public void setUrdu(String urdu)
this.urdu = urdu;
public String getEnglish()
return english;
public void setEnglish(String english)
this.english = english;
This is the surah no and surah name getter setter class
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SurahResponse
@SerializedName("surah_no")
@Expose
private Integer surahNo;
@SerializedName("total_ayah")
@Expose
private Integer totalAyah;
@SerializedName("name")
@Expose
private String name;
@SerializedName("detail")
@Expose
private List<AyatDetail> detail = null;
public Integer getSurahNo()
return surahNo;
public void setSurahNo(Integer surahNo)
this.surahNo = surahNo;
public Integer getTotalAyah()
return totalAyah;
public void setTotalAyah(Integer totalAyah)
this.totalAyah = totalAyah;
public String getName()
return name;
public void setName(String name)
this.name = name;
public List<AyatDetail> getDetail()
return detail;
public void setDetail(List<AyatDetail> detail)
this.detail = detail;
When i click on the first index in listview the logcat gives an error of included below
Process: com.example.osamasaleem.prayertimes, PID: 31057
android.content.ActivityNotFoundException: Unable to find explicit activity class com.example.osamasaleem.prayertimes/com.example.prayertimes.timetoperformprayers.QuranData.Surah; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1895)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1589)
at android.app.Activity.startActivityForResult(Activity.java:4234)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:4192)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at android.app.Activity.startActivity(Activity.java:4535)
at android.app.Activity.startActivity(Activity.java:4503)
at com.example.prayertimes.timetoperformprayers.QuranVersions$1.onItemClick(QuranVersions.java:42)
at android.widget.AdapterView.performItemClick(AdapterView.java:315)
at android.widget.AbsListView.performItemClick(AbsListView.java:1210)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3349)
at android.widget.AbsListView$4.run(AbsListView.java:4410)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6339)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
This is my 41 line number
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
}
How can I fix this Logcat error?
java sharedpreferences
1
Great, thanks. Also, please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
– halfer
Nov 16 '18 at 20:09
Thanks for letting me know about this site :)
– Osama Saleem
Nov 17 '18 at 17:47
add a comment |
This is my MainClass where I am showing the Listview as a Surah List
package com.example.prayertimes.timetoperformprayers;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.ArrayAdapter;
import com.example.prayertimes.timetoperformingprayers.R;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SharedSurahPref;
import com.example.prayertimes.timetoperformprayers.QuranData.Surah;
import java.util.ArrayList;
import java.util.List;
import android.widget.TextView;
public class QuranVersions extends AppCompatActivity
List<String> SurahList;
ListView SurahListName;
TextView Ayah;
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
private void prepareDate()
SurahList = new ArrayList<>();
SurahList.add("1 Surah Al-Fatihah");
SurahList.add("2 Surah Al-Baqara");
SurahList.add("3 Surah Al-i'Imran");
SurahList.add("4 Surah An-Nisaa");
SurahList.add("5 Surah Al-Maidah");
SurahList.add("6 Surah Al-An'am");
SurahList.add("7 Surah Al-A'raf");
SurahList.add("8 Surah Al-Anfal");
SurahList.add("9 Surah At-Tauba");
SurahList.add("10 Surah Yunus");
SurahList.add("11 Surah Hud");
SurahList.add("12 Surah Yusuf");
SurahList.add("13 Surah Ar-Ra'd");
SurahList.add("14 Surah Ibrahim");
SurahList.add("15 Surah Al-Hijr");
SurahList.add("16 Surah An-Nahl");
SurahList.add("17 Surah Al-Israa");
SurahList.add("18 Surah Al-Kahf");
SurahList.add("19 Surah Maryam");
SurahList.add("20 Surah Ta-ha");
SurahList.add("21 Surah Al-Anbiyaa");
SurahList.add("22 Surah Al-Hajj");
SurahList.add("23 Surah Al-Muminun");
SurahList.add("24 Surah An-Nur");
SurahList.add("25 Surah Al-Furqan");
SurahList.add("26 Surah Ash-Shu'araa");
SurahList.add("27 Surah An-Naml");
SurahList.add("28 Surah Al-Qasas");
SurahList.add("29 Surah Al-Ankabut");
SurahList.add("30 Surah Ar-Rum");
SurahList.add("31 Surah Luqman");
SurahList.add("32 Surah As-Sajda");
SurahList.add("33 Surah Al-Ahzab");
SurahList.add("34 Surah Saba");
SurahList.add("35 Surah Fatir");
SurahList.add("36 Surah Ya-Sin");
SurahList.add("37 Surah As-Saffat");
SurahList.add("38 Surah Sad");
SurahList.add("39 Surah Az-Zumar");
SurahList.add("40 Surah Al-Mu'min");
SurahList.add("41 Surah Ha-Mim");
SurahList.add("42 Surah Ash-Shura");
SurahList.add("43 Surah Az-Zukhruf");
SurahList.add("44 Surah Ad-Dukhan");
SurahList.add("45 Surah Al-Jathiya");
SurahList.add("46 Surah Al-Ahqaf");
SurahList.add("47 Surah Muhammad");
SurahList.add("48 Surah Al-Fat-h");
SurahList.add("49 Surah Al-Hujurat");
SurahList.add("50 Surah Qaf");
SurahList.add("51 Surah Az-Zariyat");
SurahList.add("52 Surah At-Tur");
SurahList.add("53 Surah An-Najm");
SurahList.add("54 Surah Al-Qamar");
SurahList.add("55 Surah Ar-Rahman");
SurahList.add("56 Surah Al-Waqi'a");
SurahList.add("57 Surah Al-Hadid");
SurahList.add("58 Surah Al-Mujadila");
SurahList.add("59 Surah Al-Hashr");
SurahList.add("60 Surah Al-Mumtahana");
SurahList.add("61 Surah As-Saff");
SurahList.add("62 Surah Al-Jumu'a");
SurahList.add("63 Surah Al-Munafiqun");
SurahList.add("64 Surah At-Tagabun");
SurahList.add("65 Surah At-Talaq");
SurahList.add("66 Surah At-Tahrim");
SurahList.add("67 Surah Al-Mulk");
SurahList.add("68 Surah Al-Qalam");
SurahList.add("69 Surah Al-Haqqa");
SurahList.add("70 Surah Al-Ma'arij");
SurahList.add("71 Surah Nuh");
SurahList.add("72 Surah Al-Jinn");
SurahList.add("73 Surah Al-Muzzammil");
SurahList.add("74 Surah Al-Muddathth");
SurahList.add("75 Surah Al-Qiyamat");
SurahList.add("76 Surah Ad-Dahr");
SurahList.add("77 Surah Al-Mursalat");
SurahList.add("78 Surah An-Nabaa");
SurahList.add("79 Surah An-Nazi'at");
SurahList.add("80 Surah Abasa");
SurahList.add("81 Surah At-Takwir");
SurahList.add("82 Surah Al-Infitar");
SurahList.add("83 Surah Al-Mutaffifin");
SurahList.add("84 Surah Al-Inshiqaq");
SurahList.add("85 Surah Al-Buruj");
SurahList.add("86 Surah At-Tariq");
SurahList.add("87 Surah Al-A'la");
SurahList.add("88 Surah Al-Gashiya");
SurahList.add("89 Surah Al-Fajr");
SurahList.add("90 Surah Al-Balad");
SurahList.add("91 Surah Ash-Shams");
SurahList.add("92 Surah Al-Lail");
SurahList.add("93 Surah Adh-Dhuha");
SurahList.add("94 Surah Al-Sharh");
SurahList.add("95 Surah At-Tin");
SurahList.add("96 Surah Al-Alaq");
SurahList.add("97 Surah Al-Qadr");
SurahList.add("98 Surah Al-Baiyina");
SurahList.add("99 Surah Al-Zalzalah");
SurahList.add("100 Surah Al-Adiyat");
SurahList.add("101 Surah Al-Qari'a");
SurahList.add("102 Surah At-Takathur");
SurahList.add("103 Surah Al-Asr");
SurahList.add("104 Surah Al-Humaza");
SurahList.add("105 Surah Al-Fil");
SurahList.add("106 Surah Quraish");
SurahList.add("107 Surah Al-Ma'un");
SurahList.add("108 Surah Al-Kauthar");
SurahList.add("109 Surah Al-Kafirun");
SurahList.add("110 Surah An-Nasr");
SurahList.add("111 Surah Al-Lahab");
SurahList.add("112 Surah Al-Ikhlas");
SurahList.add("113 Surah Al-Falaq");
SurahList.add("114 Surah Al-Nas");
// Read the company.json file and convert it to a java object.
This is my XML file of this class
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp"
tools:context="com.example.prayertimes.timetoperformprayers.QuranVersions">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/ayah"
android:text=""/>
<ListView
android:id="@+id/quranAyahList"
android:layout_gravity="center"
android:gravity="center"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
This is my Surah file where I am parsing json data
Surah.Java
package com.example.prayertimes.timetoperformprayers.QuranData;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.example.prayertimes.timetoperformingprayers.R;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SharedSurahPref;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SurahResponse;
import com.google.gson.Gson;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class Surah extends AppCompatActivity
ListView AyatDetail;
List<String> ayatLDetail;
TextView totalAyat, surahNum, surahName;
int selectedSurrahIndex = 0;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_surah);
selectedSurrahIndex = getIntent().getIntExtra("index",0);
generateSurahData(selectedSurrahIndex);
setUpUiView();
final ArrayAdapter<String> ayatList = new ArrayAdapter<String>(Surah.this, android.R.layout.simple_list_item_1, ayatLDetail);
AyatDetail.setAdapter(ayatList);
private void setUpUiView()
totalAyat = findViewById(R.id.totalAyah);
surahNum = findViewById(R.id.surahNo);
surahName = findViewById(R.id.surahName);
AyatDetail = (ListView) findViewById(R.id.AyatDetail);
private void generateSurahData(int surrahIndex)
if(!SharedSurahPref.allSurah.containsKey(surrahIndex))
InputStream inputStream = getResources().openRawResource(SharedSurahPref.SurrahNames.get(surrahIndex));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int ctr;
try
ctr = inputStream.read();
while (ctr != -1)
byteArrayOutputStream.write(ctr);
ctr = inputStream.read();
inputStream.close();
catch (IOException e)
e.printStackTrace();
Log.v("Text Data", byteArrayOutputStream.toString());
try
// Parse the data into json object to get original data in form of json.
JSONObject jObject = new JSONObject(byteArrayOutputStream.toString());
SurahResponse model = new Gson().fromJson(jObject.toString(), SurahResponse.class);
SharedSurahPref.allSurah.put(surrahIndex, model);
if (SharedSurahPref.allSurah.size() > surrahIndex)
totalAyat.setText(SharedSurahPref.allSurah.get(surrahIndex).getTotalAyah());
surahNum.setText(SharedSurahPref.allSurah.get(surrahIndex).getSurahNo()+"");
totalAyat.setText(SharedSurahPref.allSurah.get(surrahIndex).getTotalAyah()+"");
ayatLDetail.add(SharedSurahPref.detailHashMap.get(surrahIndex).getArbi());
catch (Exception e)
e.printStackTrace();
This is the XML file of Surah.java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context="com.example.prayertimes.timetoperformprayers.QuranData.Surah">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/totalAyah"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/surahNo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/surahName"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ayatNum"/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/AyatDetail"/>
</LinearLayout>
This is the SharefSurahPref.class where all the json files are parsing to the surah activity
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import android.view.View;
import com.example.prayertimes.timetoperformingprayers.R;
import com.google.android.gms.flags.impl.SharedPreferencesFactory;
import java.util.ArrayList;
import java.util.HashMap;
public class SharedSurahPref extends SharedPreferencesFactory
public static ArrayList<Integer> SurrahNames = new ArrayList<>();
public static HashMap<Integer,SurahResponse> allSurah = new HashMap<>();
public static HashMap<String, AyatDetail> detailHashMap = new HashMap();
SharedSurahPref()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
This is the Ayat Verses getter and setters
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class AyatDetail extends SurahResponse
@SerializedName("ayet_no")
@Expose
private Integer ayetNo;
@SerializedName("arbi")
@Expose
private String arbi;
@SerializedName("Urdu")
@Expose
private String urdu;
@SerializedName("English")
@Expose
private String english;
public Integer getAyetNo()
return ayetNo;
public void setAyetNo(Integer ayetNo)
this.ayetNo = ayetNo;
public String getArbi()
return arbi;
public void setArbi(String arbi)
this.arbi = arbi;
public String getUrdu()
return urdu;
public void setUrdu(String urdu)
this.urdu = urdu;
public String getEnglish()
return english;
public void setEnglish(String english)
this.english = english;
This is the surah no and surah name getter setter class
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SurahResponse
@SerializedName("surah_no")
@Expose
private Integer surahNo;
@SerializedName("total_ayah")
@Expose
private Integer totalAyah;
@SerializedName("name")
@Expose
private String name;
@SerializedName("detail")
@Expose
private List<AyatDetail> detail = null;
public Integer getSurahNo()
return surahNo;
public void setSurahNo(Integer surahNo)
this.surahNo = surahNo;
public Integer getTotalAyah()
return totalAyah;
public void setTotalAyah(Integer totalAyah)
this.totalAyah = totalAyah;
public String getName()
return name;
public void setName(String name)
this.name = name;
public List<AyatDetail> getDetail()
return detail;
public void setDetail(List<AyatDetail> detail)
this.detail = detail;
When i click on the first index in listview the logcat gives an error of included below
Process: com.example.osamasaleem.prayertimes, PID: 31057
android.content.ActivityNotFoundException: Unable to find explicit activity class com.example.osamasaleem.prayertimes/com.example.prayertimes.timetoperformprayers.QuranData.Surah; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1895)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1589)
at android.app.Activity.startActivityForResult(Activity.java:4234)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:4192)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at android.app.Activity.startActivity(Activity.java:4535)
at android.app.Activity.startActivity(Activity.java:4503)
at com.example.prayertimes.timetoperformprayers.QuranVersions$1.onItemClick(QuranVersions.java:42)
at android.widget.AdapterView.performItemClick(AdapterView.java:315)
at android.widget.AbsListView.performItemClick(AbsListView.java:1210)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3349)
at android.widget.AbsListView$4.run(AbsListView.java:4410)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6339)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
This is my 41 line number
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
}
How can I fix this Logcat error?
java sharedpreferences
This is my MainClass where I am showing the Listview as a Surah List
package com.example.prayertimes.timetoperformprayers;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.ArrayAdapter;
import com.example.prayertimes.timetoperformingprayers.R;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SharedSurahPref;
import com.example.prayertimes.timetoperformprayers.QuranData.Surah;
import java.util.ArrayList;
import java.util.List;
import android.widget.TextView;
public class QuranVersions extends AppCompatActivity
List<String> SurahList;
ListView SurahListName;
TextView Ayah;
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
private void prepareDate()
SurahList = new ArrayList<>();
SurahList.add("1 Surah Al-Fatihah");
SurahList.add("2 Surah Al-Baqara");
SurahList.add("3 Surah Al-i'Imran");
SurahList.add("4 Surah An-Nisaa");
SurahList.add("5 Surah Al-Maidah");
SurahList.add("6 Surah Al-An'am");
SurahList.add("7 Surah Al-A'raf");
SurahList.add("8 Surah Al-Anfal");
SurahList.add("9 Surah At-Tauba");
SurahList.add("10 Surah Yunus");
SurahList.add("11 Surah Hud");
SurahList.add("12 Surah Yusuf");
SurahList.add("13 Surah Ar-Ra'd");
SurahList.add("14 Surah Ibrahim");
SurahList.add("15 Surah Al-Hijr");
SurahList.add("16 Surah An-Nahl");
SurahList.add("17 Surah Al-Israa");
SurahList.add("18 Surah Al-Kahf");
SurahList.add("19 Surah Maryam");
SurahList.add("20 Surah Ta-ha");
SurahList.add("21 Surah Al-Anbiyaa");
SurahList.add("22 Surah Al-Hajj");
SurahList.add("23 Surah Al-Muminun");
SurahList.add("24 Surah An-Nur");
SurahList.add("25 Surah Al-Furqan");
SurahList.add("26 Surah Ash-Shu'araa");
SurahList.add("27 Surah An-Naml");
SurahList.add("28 Surah Al-Qasas");
SurahList.add("29 Surah Al-Ankabut");
SurahList.add("30 Surah Ar-Rum");
SurahList.add("31 Surah Luqman");
SurahList.add("32 Surah As-Sajda");
SurahList.add("33 Surah Al-Ahzab");
SurahList.add("34 Surah Saba");
SurahList.add("35 Surah Fatir");
SurahList.add("36 Surah Ya-Sin");
SurahList.add("37 Surah As-Saffat");
SurahList.add("38 Surah Sad");
SurahList.add("39 Surah Az-Zumar");
SurahList.add("40 Surah Al-Mu'min");
SurahList.add("41 Surah Ha-Mim");
SurahList.add("42 Surah Ash-Shura");
SurahList.add("43 Surah Az-Zukhruf");
SurahList.add("44 Surah Ad-Dukhan");
SurahList.add("45 Surah Al-Jathiya");
SurahList.add("46 Surah Al-Ahqaf");
SurahList.add("47 Surah Muhammad");
SurahList.add("48 Surah Al-Fat-h");
SurahList.add("49 Surah Al-Hujurat");
SurahList.add("50 Surah Qaf");
SurahList.add("51 Surah Az-Zariyat");
SurahList.add("52 Surah At-Tur");
SurahList.add("53 Surah An-Najm");
SurahList.add("54 Surah Al-Qamar");
SurahList.add("55 Surah Ar-Rahman");
SurahList.add("56 Surah Al-Waqi'a");
SurahList.add("57 Surah Al-Hadid");
SurahList.add("58 Surah Al-Mujadila");
SurahList.add("59 Surah Al-Hashr");
SurahList.add("60 Surah Al-Mumtahana");
SurahList.add("61 Surah As-Saff");
SurahList.add("62 Surah Al-Jumu'a");
SurahList.add("63 Surah Al-Munafiqun");
SurahList.add("64 Surah At-Tagabun");
SurahList.add("65 Surah At-Talaq");
SurahList.add("66 Surah At-Tahrim");
SurahList.add("67 Surah Al-Mulk");
SurahList.add("68 Surah Al-Qalam");
SurahList.add("69 Surah Al-Haqqa");
SurahList.add("70 Surah Al-Ma'arij");
SurahList.add("71 Surah Nuh");
SurahList.add("72 Surah Al-Jinn");
SurahList.add("73 Surah Al-Muzzammil");
SurahList.add("74 Surah Al-Muddathth");
SurahList.add("75 Surah Al-Qiyamat");
SurahList.add("76 Surah Ad-Dahr");
SurahList.add("77 Surah Al-Mursalat");
SurahList.add("78 Surah An-Nabaa");
SurahList.add("79 Surah An-Nazi'at");
SurahList.add("80 Surah Abasa");
SurahList.add("81 Surah At-Takwir");
SurahList.add("82 Surah Al-Infitar");
SurahList.add("83 Surah Al-Mutaffifin");
SurahList.add("84 Surah Al-Inshiqaq");
SurahList.add("85 Surah Al-Buruj");
SurahList.add("86 Surah At-Tariq");
SurahList.add("87 Surah Al-A'la");
SurahList.add("88 Surah Al-Gashiya");
SurahList.add("89 Surah Al-Fajr");
SurahList.add("90 Surah Al-Balad");
SurahList.add("91 Surah Ash-Shams");
SurahList.add("92 Surah Al-Lail");
SurahList.add("93 Surah Adh-Dhuha");
SurahList.add("94 Surah Al-Sharh");
SurahList.add("95 Surah At-Tin");
SurahList.add("96 Surah Al-Alaq");
SurahList.add("97 Surah Al-Qadr");
SurahList.add("98 Surah Al-Baiyina");
SurahList.add("99 Surah Al-Zalzalah");
SurahList.add("100 Surah Al-Adiyat");
SurahList.add("101 Surah Al-Qari'a");
SurahList.add("102 Surah At-Takathur");
SurahList.add("103 Surah Al-Asr");
SurahList.add("104 Surah Al-Humaza");
SurahList.add("105 Surah Al-Fil");
SurahList.add("106 Surah Quraish");
SurahList.add("107 Surah Al-Ma'un");
SurahList.add("108 Surah Al-Kauthar");
SurahList.add("109 Surah Al-Kafirun");
SurahList.add("110 Surah An-Nasr");
SurahList.add("111 Surah Al-Lahab");
SurahList.add("112 Surah Al-Ikhlas");
SurahList.add("113 Surah Al-Falaq");
SurahList.add("114 Surah Al-Nas");
// Read the company.json file and convert it to a java object.
This is my XML file of this class
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp"
tools:context="com.example.prayertimes.timetoperformprayers.QuranVersions">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/ayah"
android:text=""/>
<ListView
android:id="@+id/quranAyahList"
android:layout_gravity="center"
android:gravity="center"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
This is my Surah file where I am parsing json data
Surah.Java
package com.example.prayertimes.timetoperformprayers.QuranData;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.example.prayertimes.timetoperformingprayers.R;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SharedSurahPref;
import com.example.prayertimes.timetoperformprayers.PojoQuran.SurahResponse;
import com.google.gson.Gson;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class Surah extends AppCompatActivity
ListView AyatDetail;
List<String> ayatLDetail;
TextView totalAyat, surahNum, surahName;
int selectedSurrahIndex = 0;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_surah);
selectedSurrahIndex = getIntent().getIntExtra("index",0);
generateSurahData(selectedSurrahIndex);
setUpUiView();
final ArrayAdapter<String> ayatList = new ArrayAdapter<String>(Surah.this, android.R.layout.simple_list_item_1, ayatLDetail);
AyatDetail.setAdapter(ayatList);
private void setUpUiView()
totalAyat = findViewById(R.id.totalAyah);
surahNum = findViewById(R.id.surahNo);
surahName = findViewById(R.id.surahName);
AyatDetail = (ListView) findViewById(R.id.AyatDetail);
private void generateSurahData(int surrahIndex)
if(!SharedSurahPref.allSurah.containsKey(surrahIndex))
InputStream inputStream = getResources().openRawResource(SharedSurahPref.SurrahNames.get(surrahIndex));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int ctr;
try
ctr = inputStream.read();
while (ctr != -1)
byteArrayOutputStream.write(ctr);
ctr = inputStream.read();
inputStream.close();
catch (IOException e)
e.printStackTrace();
Log.v("Text Data", byteArrayOutputStream.toString());
try
// Parse the data into json object to get original data in form of json.
JSONObject jObject = new JSONObject(byteArrayOutputStream.toString());
SurahResponse model = new Gson().fromJson(jObject.toString(), SurahResponse.class);
SharedSurahPref.allSurah.put(surrahIndex, model);
if (SharedSurahPref.allSurah.size() > surrahIndex)
totalAyat.setText(SharedSurahPref.allSurah.get(surrahIndex).getTotalAyah());
surahNum.setText(SharedSurahPref.allSurah.get(surrahIndex).getSurahNo()+"");
totalAyat.setText(SharedSurahPref.allSurah.get(surrahIndex).getTotalAyah()+"");
ayatLDetail.add(SharedSurahPref.detailHashMap.get(surrahIndex).getArbi());
catch (Exception e)
e.printStackTrace();
This is the XML file of Surah.java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context="com.example.prayertimes.timetoperformprayers.QuranData.Surah">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/totalAyah"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/surahNo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/surahName"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ayatNum"/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/AyatDetail"/>
</LinearLayout>
This is the SharefSurahPref.class where all the json files are parsing to the surah activity
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import android.view.View;
import com.example.prayertimes.timetoperformingprayers.R;
import com.google.android.gms.flags.impl.SharedPreferencesFactory;
import java.util.ArrayList;
import java.util.HashMap;
public class SharedSurahPref extends SharedPreferencesFactory
public static ArrayList<Integer> SurrahNames = new ArrayList<>();
public static HashMap<Integer,SurahResponse> allSurah = new HashMap<>();
public static HashMap<String, AyatDetail> detailHashMap = new HashMap();
SharedSurahPref()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
This is the Ayat Verses getter and setters
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class AyatDetail extends SurahResponse
@SerializedName("ayet_no")
@Expose
private Integer ayetNo;
@SerializedName("arbi")
@Expose
private String arbi;
@SerializedName("Urdu")
@Expose
private String urdu;
@SerializedName("English")
@Expose
private String english;
public Integer getAyetNo()
return ayetNo;
public void setAyetNo(Integer ayetNo)
this.ayetNo = ayetNo;
public String getArbi()
return arbi;
public void setArbi(String arbi)
this.arbi = arbi;
public String getUrdu()
return urdu;
public void setUrdu(String urdu)
this.urdu = urdu;
public String getEnglish()
return english;
public void setEnglish(String english)
this.english = english;
This is the surah no and surah name getter setter class
package com.example.prayertimes.timetoperformprayers.PojoQuran;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SurahResponse
@SerializedName("surah_no")
@Expose
private Integer surahNo;
@SerializedName("total_ayah")
@Expose
private Integer totalAyah;
@SerializedName("name")
@Expose
private String name;
@SerializedName("detail")
@Expose
private List<AyatDetail> detail = null;
public Integer getSurahNo()
return surahNo;
public void setSurahNo(Integer surahNo)
this.surahNo = surahNo;
public Integer getTotalAyah()
return totalAyah;
public void setTotalAyah(Integer totalAyah)
this.totalAyah = totalAyah;
public String getName()
return name;
public void setName(String name)
this.name = name;
public List<AyatDetail> getDetail()
return detail;
public void setDetail(List<AyatDetail> detail)
this.detail = detail;
When i click on the first index in listview the logcat gives an error of included below
Process: com.example.osamasaleem.prayertimes, PID: 31057
android.content.ActivityNotFoundException: Unable to find explicit activity class com.example.osamasaleem.prayertimes/com.example.prayertimes.timetoperformprayers.QuranData.Surah; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1895)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1589)
at android.app.Activity.startActivityForResult(Activity.java:4234)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:4192)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at android.app.Activity.startActivity(Activity.java:4535)
at android.app.Activity.startActivity(Activity.java:4503)
at com.example.prayertimes.timetoperformprayers.QuranVersions$1.onItemClick(QuranVersions.java:42)
at android.widget.AdapterView.performItemClick(AdapterView.java:315)
at android.widget.AbsListView.performItemClick(AbsListView.java:1210)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3349)
at android.widget.AbsListView$4.run(AbsListView.java:4410)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6339)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
This is my 41 line number
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
}
How can I fix this Logcat error?
java sharedpreferences
java sharedpreferences
edited Nov 16 '18 at 20:07
halfer
14.7k759116
14.7k759116
asked Nov 15 '18 at 8:18
Osama SaleemOsama Saleem
63
63
1
Great, thanks. Also, please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
– halfer
Nov 16 '18 at 20:09
Thanks for letting me know about this site :)
– Osama Saleem
Nov 17 '18 at 17:47
add a comment |
1
Great, thanks. Also, please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
– halfer
Nov 16 '18 at 20:09
Thanks for letting me know about this site :)
– Osama Saleem
Nov 17 '18 at 17:47
1
1
Great, thanks. Also, please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
– halfer
Nov 16 '18 at 20:09
Great, thanks. Also, please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
– halfer
Nov 16 '18 at 20:09
Thanks for letting me know about this site :)
– Osama Saleem
Nov 17 '18 at 17:47
Thanks for letting me know about this site :)
– Osama Saleem
Nov 17 '18 at 17:47
add a comment |
1 Answer
1
active
oldest
votes
I did some changes in QuranVersions.java (That is the SurahList in Above Question)
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index", position+""));
//startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
And In SharedSurahPref.java just created a static function
public static void initialization()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
And called this function inside the launcher activity in manifest
SharedSurahPref.initialization();
This is how i resolved this but i'm still not getting the json data in text view and its actually not picking up the json data it getting null
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315042%2ferror-getting-on-parsing-json-data-with-getting-positions-in-listview%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I did some changes in QuranVersions.java (That is the SurahList in Above Question)
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index", position+""));
//startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
And In SharedSurahPref.java just created a static function
public static void initialization()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
And called this function inside the launcher activity in manifest
SharedSurahPref.initialization();
This is how i resolved this but i'm still not getting the json data in text view and its actually not picking up the json data it getting null
add a comment |
I did some changes in QuranVersions.java (That is the SurahList in Above Question)
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index", position+""));
//startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
And In SharedSurahPref.java just created a static function
public static void initialization()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
And called this function inside the launcher activity in manifest
SharedSurahPref.initialization();
This is how i resolved this but i'm still not getting the json data in text view and its actually not picking up the json data it getting null
add a comment |
I did some changes in QuranVersions.java (That is the SurahList in Above Question)
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index", position+""));
//startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
And In SharedSurahPref.java just created a static function
public static void initialization()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
And called this function inside the launcher activity in manifest
SharedSurahPref.initialization();
This is how i resolved this but i'm still not getting the json data in text view and its actually not picking up the json data it getting null
I did some changes in QuranVersions.java (That is the SurahList in Above Question)
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quran_versions);
Ayah = (TextView)findViewById(R.id.ayah);
prepareDate();
SurahListName = (ListView)findViewById(R.id.quranAyahList);
final ArrayAdapter<String> surahLists = new ArrayAdapter<String>(QuranVersions.this, android.R.layout.simple_list_item_1,SurahList);
SurahListName.setAdapter(surahLists);
SurahListName.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index", position+""));
//startActivity(new Intent(QuranVersions.this, Surah.class).putExtra("index",position));
);
And In SharedSurahPref.java just created a static function
public static void initialization()
SurrahNames.add(R.raw.surah_e_fateh_1);
SurrahNames.add(R.raw.surah_e_bakra_2);
SurrahNames.add(R.raw.surah_e_imran_3);
SurrahNames.add(R.raw.surah_e_nisa_4);
SurrahNames.add(R.raw.surah_e_maida_5);
SurrahNames.add(R.raw.surah_e_inaam_6);
SurrahNames.add(R.raw.surah_e_araaf_7);
SurrahNames.add(R.raw.surah_e_infaal_8);
SurrahNames.add(R.raw.surah_e_tobah_9);
SurrahNames.add(R.raw.surah_e_younus_10);
SurrahNames.add(R.raw.surah_e_hud_11);
SurrahNames.add(R.raw.surah_e_yousaf_12);
SurrahNames.add(R.raw.surah_e_radd_13);
SurrahNames.add(R.raw.surah_e_ibrahim_14);
SurrahNames.add(R.raw.surah_e_hijar_15);
SurrahNames.add(R.raw.surah_e_nahal_16);
SurrahNames.add(R.raw.surah_e_isra_17);
SurrahNames.add(R.raw.surah_e_kahf_18);
SurrahNames.add(R.raw.surah_e_maryam_19);
SurrahNames.add(R.raw.surah_e_taha_20);
SurrahNames.add(R.raw.surah_e_ambiyaa_21);
SurrahNames.add(R.raw.surah_e_hajj_22);
SurrahNames.add(R.raw.surah_e_muminun_23);
SurrahNames.add(R.raw.surah_noor_24);
SurrahNames.add(R.raw.surah_e_furqaan_25);
SurrahNames.add(R.raw.surah_e_shaer_26);
SurrahNames.add(R.raw.surah_e_naml_27);
SurrahNames.add(R.raw.surah_e_qasas_28);
SurrahNames.add(R.raw.surah_e_ankabut_29);
SurrahNames.add(R.raw.surah_e_rom_30);
SurrahNames.add(R.raw.surah_e_luqman_31);
SurrahNames.add(R.raw.surah_e_sajda_32);
SurrahNames.add(R.raw.surah_e_ahzaab_33);
SurrahNames.add(R.raw.surah_e_saba_34);
SurrahNames.add(R.raw.surah_e_fatir_35);
SurrahNames.add(R.raw.surah_e_yasin_36);
SurrahNames.add(R.raw.surah_e_saffat_37);
SurrahNames.add(R.raw.surah_e_sad_38);
SurrahNames.add(R.raw.surah_e_zamar_39);
SurrahNames.add(R.raw.surah_e_ghafir_40);
SurrahNames.add(R.raw.surah_e_faslat_41);
SurrahNames.add(R.raw.surah_e_shuara_42);
SurrahNames.add(R.raw.surah_e_zakhruf_43);
SurrahNames.add(R.raw.surah_e_dakhan_44);
SurrahNames.add(R.raw.surah_e_jasiya_45);
SurrahNames.add(R.raw.surah_e_ahkaf_46);
SurrahNames.add(R.raw.surah_e_muhammad_47);
SurrahNames.add(R.raw.surah_e_al_fatah_48);
SurrahNames.add(R.raw.surah_e_al_hajrat_49);
SurrahNames.add(R.raw.surah_e_qaf_50);
SurrahNames.add(R.raw.surah_e_zariyat_51);
SurrahNames.add(R.raw.surah_e_al_toor_52);
SurrahNames.add(R.raw.surah_e_al_najam_53);
SurrahNames.add(R.raw.surah_e_al_qamar_54);
SurrahNames.add(R.raw.surah_e_ar_rehman_55);
SurrahNames.add(R.raw.surah_e_al_waqiah_56);
SurrahNames.add(R.raw.surah_e_al_hadid_57);
SurrahNames.add(R.raw.surah_e_al_mujadillah_58);
SurrahNames.add(R.raw.surah_e_al_hashar_59);
SurrahNames.add(R.raw.surah_e_al_mumtahina_60);
SurrahNames.add(R.raw.surah_e_al_saf_61);
SurrahNames.add(R.raw.surah_e_al_jummah_62);
SurrahNames.add(R.raw.surah_e_al_munafiqun_63);
SurrahNames.add(R.raw.surah_e_al_taghabun_64);
SurrahNames.add(R.raw.surah_e_al_talaq_65);
SurrahNames.add(R.raw.surah_e_al_tehrim_66);
SurrahNames.add(R.raw.surah_e_al_mulk_67);
SurrahNames.add(R.raw.surah_e_al_qalam_68);
SurrahNames.add(R.raw.surah_e_al_haqah_69);
SurrahNames.add(R.raw.surah_e_al_meeraj_70);
SurrahNames.add(R.raw.surah_e_noah_71);
SurrahNames.add(R.raw.surah_e_al_jinn_72);
SurrahNames.add(R.raw.surah_e_al_muzamil_73);
SurrahNames.add(R.raw.surah_e_al_mudasir_74);
SurrahNames.add(R.raw.surah_e_al_qiyamah_75);
SurrahNames.add(R.raw.surah_e_al_insan_76);
SurrahNames.add(R.raw.surah_e_al_mursalat_77);
SurrahNames.add(R.raw.surah_e_naba_78);
SurrahNames.add(R.raw.surah_e_al_naziat_79);
SurrahNames.add(R.raw.surah_e_abas_80);
SurrahNames.add(R.raw.surah_e_at_takwir_81);
SurrahNames.add(R.raw.surah_e_al_infitar_82);
SurrahNames.add(R.raw.surah_e_al_mutaffifin_83);
SurrahNames.add(R.raw.surah_e_al_inshiqaq_84);
SurrahNames.add(R.raw.surah_e_al_buruj_85);
SurrahNames.add(R.raw.surah_e_at_tariq_86);
SurrahNames.add(R.raw.surah_e_al_aala_87);
SurrahNames.add(R.raw.surah_e_al_ghashiyah_88);
SurrahNames.add(R.raw.surah_e_al_fajr_89);
SurrahNames.add(R.raw.surah_e_al_balad_90);
SurrahNames.add(R.raw.surah_e_ash_shams_91);
SurrahNames.add(R.raw.surah_e_al_lail_92);
SurrahNames.add(R.raw.surah_e_ad_duha_93);
SurrahNames.add(R.raw.surah_e_an_nashrah_94);
SurrahNames.add(R.raw.surah_e_at_teen_95);
SurrahNames.add(R.raw.surah_e_al_alaq_96);
SurrahNames.add(R.raw.surah_e_al_qadr_97);
SurrahNames.add(R.raw.surah_e_al_bayyinah_98);
SurrahNames.add(R.raw.surah_e_al_zilzali_99);
SurrahNames.add(R.raw.surah_e_al_adiyaat_100);
SurrahNames.add(R.raw.surah_e_al_quriah_101);
SurrahNames.add(R.raw.surah_e_at_takasur_102);
SurrahNames.add(R.raw.surah_e_al_asr_103);
SurrahNames.add(R.raw.surah_e_al_humazah_104);
SurrahNames.add(R.raw.surah_e_al_feel_105);
SurrahNames.add(R.raw.surah_e_quraish_106);
SurrahNames.add(R.raw.surah_e_al_maoon_107);
SurrahNames.add(R.raw.surah_e_al_kausar_108);
SurrahNames.add(R.raw.surah_e_al_kafirun_109);
SurrahNames.add(R.raw.surah_e_an_nasr_110);
SurrahNames.add(R.raw.surah_e_tabbat_111);
SurrahNames.add(R.raw.surah_e_al_ikhlas_112);
SurrahNames.add(R.raw.surah_e_al_falaq_113);
SurrahNames.add(R.raw.surah_e_an_naas_114);
And called this function inside the launcher activity in manifest
SharedSurahPref.initialization();
This is how i resolved this but i'm still not getting the json data in text view and its actually not picking up the json data it getting null
answered Nov 20 '18 at 21:00
Osama SaleemOsama Saleem
63
63
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315042%2ferror-getting-on-parsing-json-data-with-getting-positions-in-listview%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Great, thanks. Also, please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
– halfer
Nov 16 '18 at 20:09
Thanks for letting me know about this site :)
– Osama Saleem
Nov 17 '18 at 17:47