How I can make a small icon to stay in screen to toggle and untoggle the application so it can be used and accessed easily when opening other apps?

Same thing like facebook messenger icon which appears with draggable tab like this:

enter image description here

I'm using Mapview with React-Native (react-native-maps) on Android, and I got this :

https://cloud.githubusercontent.com/assets/11644230/19089605/4fac71f4-8a7b-11e6-998d-9a41461b2c16.png

Problem is : I have "2 Maps rendered", one in front of which can't moove and another "small" on the top of the screen which is working... (in the background) As you can see on my picture, the fix map is on San Francisco and the other small one mooved to Green Valley ...

Do you know how I can fix this ?

Here is my javascript file :

// Fonction qui récupère la position actuelle de l'utilisateur
getCurrrentPosition() {
    // Permet de vérifier que la fonction s'exécute bien que lorsqu'on clique sur le bouton "get position"
    //console.log("execute");
    navigator.geolocation.getCurrentPosition(
        (position) => {
            var current_position = JSON.stringify(position);
            // C'est comme ça qu'on récupère la lattitude et la longitude car positon corresponds à un json (affiché dans current_position)
            //console.log("lattitude "+position.coords.latitude);

            // On set les différents state récupérés avec la position...
            this.setState({current_position});
            this.setState({latitude:position.coords.latitude});
            this.setState({longitude:position.coords.longitude});

        },
        (error) => alert(JSON.stringify(error)),
        {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
    );
}


render() {
    return (
        <View style={styles.container}>
            <Text> Geolocalisation: </Text>
            <Text>
                <Text style={styles.title}>Position actuelle: </Text>
                {this.state.current_position}
            </Text>
            {/*Bouton qui récupère la position*/}
            <TouchableHighlight onPress={() =>  this.getCurrrentPosition()} style={styles.button}>
                <Text style={styles.buttonText}>Get current position </Text>
            </TouchableHighlight>

            {/*Affichage de la lattitude et de la longitude*/}
            <Text>Latitude : {this.state.latitude}</Text>
            <Text>Longitude : {this.state.longitude}</Text>
            <MapView  style={styles.container}
                initialRegion={{
                    latitude: 37.78825,
                    longitude: -122.4324,
                    latitudeDelta: 0.0922,
                    longitudeDelta: 0.0421,
                }}
            />


        </View>
    )
}

}

// here my StyleSheet (except container)

map: {
},
welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
},
instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
},
navigator: {
    flex: 1,
},
scrollView: {
    marginTop: 64
},
row: {
    padding: 15,
    backgroundColor: 'white',
    borderBottomWidth: 1 / PixelRatio.get(),
    borderBottomColor: '#CDCDCD',
},
rowText: {
    fontSize: 17,
},
button: {
    height: 40,
    backgroundColor: 'blue',
    borderColor: 'blue',
},
    buttonText: {
    fontSize: 17,
    fontWeight: '500',
        color:'white',
},

Thanks a lot for your help !

My application calls 4 different asynchtask. Many times the application works as expected, but sometimes it crashes with the error in asynchtask.

Here is my logcat

10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err: java.io.IOException: Attempted read on closed stream.
10-05 10:57:30.282 27705-27785/com.malav.holistree E/JSON Parser: Error parsing data org.json.JSONException: End of input at character 0 of 
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at org.apache.http.conn.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:132)
10-05 10:57:30.282 27705-27785/com.malav.holistree W/System.err:    at org.json.JSONException: End of input at character 0 of 
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err: org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:162)
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at java.io.InputStreamReader.read(InputStreamReader.java:233)
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at java.io.BufferedReader.fillBuf(BufferedReader.java:145)
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at java.io.BufferedReader.readLine(BufferedReader.java:397)
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at com.malav.holistree.util.JSONfunctions.makeHttpRequest(JSONfunctions.java:126)
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at com.malav.holistree.dashboard.DashboardFragment$fetchQuote.doInBackground(DashboardFragment.java:492)
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at     at com.malav.holistree.dashboard.DashboardFragment$fetchQuote.doInBackground(DashboardFragment.java:476)
10-05 10:57:30.282 27705-27785/com.malav.holistree W/System.err:     at org.json.JSONTokener.syntaxError(JSONTokener.java:449)
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
10-05 10:57:30.282 27705-27785/com.malav.holistree W/System.err:     at org.json.JSONTokener.nextValue(JSONTokener.java:97)
10-05 10:57:30.282 27705-27781/com.malav.holistree W/System.err:     at    java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-05 10:57:30.282 27705-27785/com.malav.holistree W/System.err:     at org.json.JSONObject.<init>(JSONObject.java:156)
10-05 10:57:30.283 27705-27785/com.malav.holistree W/System.err:     at org.json.JSONObject.<init>(JSONObject.java:173)
10-05 10:57:30.283 27705-27785/com.malav.holistree W/System.err:     at com.malav.holistree.util.JSONfunctions.makeHttpRequest(JSONfunctions.java:141)
10-05 10:57:30.283 27705-27785/com.malav.holistree W/System.err:     at com.malav.holistree.notification.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:79)
10-05 10:57:30.283 27705-27785/com.malav.holistree W/System.err:     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
10-05 10:57:30.283 27705-27785/com.malav.holistree W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
10-05 10:57:30.283 27705-27785/com.malav.holistree W/System.err:     at android.os.Looper.loop(Looper.java:148)
10-05 10:57:30.283 27705-27785/com.malav.holistree W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:61)
10-05 10:57:30.283 27705-27781/com.malav.holistree W/System.err: android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
10-05 10:57:30.283 27705-27781/com.malav.holistree W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at java.lang.Thread.run(Thread.java:818)
10-05 10:57:30.284 27705-27781/com.malav.holistree E/JSON Parser: Error parsing data org.json.JSONException: End of input at character 0 of 
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err: org.json.JSONException: End of input at character 0 of 
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at org.json.JSONTokener.syntaxError(JSONTokener.java:449)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at org.json.JSONTokener.nextValue(JSONTokener.java:97)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at org.json.JSONObject.<init>(JSONObject.java:156)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at org.json.JSONObject.<init>(JSONObject.java:173)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at com.malav.holistree.util.JSONfunctions.makeHttpRequest(JSONfunctions.java:141)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at com.malav.holistree.dashboard.DashboardFragment$fetchQuote.doInBackground(DashboardFragment.java:492)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at com.malav.holistree.dashboard.DashboardFragment$fetchQuote.doInBackground(DashboardFragment.java:476)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-05 10:57:30.284 27705-27781/com.malav.holistree W/System.err:     at java.lang.Thread.run(Thread.java:818)
10-05 10:57:30.287 27705-27781/com.malav.holistree E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                                 Process: com.malav.holistree, PID: 27705
                                                                 java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                     at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                     at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                     at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                     at java.lang.Thread.run(Thread.java:818)
                                                                  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'org.json.JSONArray org.json.JSONObject.getJSONArray(java.lang.String)' on a null object reference
                                                                     at com.malav.holistree.dashboard.DashboardFragment$fetchQuote.doInBackground(DashboardFragment.java:495)
                                                                     at com.malav.holistree.dashboard.DashboardFragment$fetchQuote.doInBackground(DashboardFragment.java:476)
                                                                     at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                     at java.lang.Thread.run(Thread.java:818) 
10-05 10:57:30.312 27705-27720/com.malav.holistree V/FA: Activity paused, time: 171909023
10-05 10:57:30.629 27705-27720/com.malav.holistree D/FA: Application backgrounded. Logging engagement
10-05 10:57:30.632 27705-27720/com.malav.holistree I/FA: Tag Manager is not found and thus will not be used
10-05 10:57:30.635 27705-27720/com.malav.holistree D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=3710}]
10-05 10:57:30.693 27705-27705/com.malav.holistree D/FirebaseApp: Notifying background state change listeners.
10-05 10:57:31.312 27705-27720/com.malav.holistree D/FA: Application backgrounded. Logging engagement
10-05 10:57:31.312 27705-27720/com.malav.holistree W/FA: Not logging non-positive engagement time: 0

Here is my Java Code

    public class DashboardFragment extends Fragment {

        List<SpinnerWithTag> studentList;
        private Activity activity;
        public Context context;
        public static String filename = "MySharedString";
        private SharedPreferences someData;
        private ListView reminderList, upcomingMeetingList;
        private EditText question;
        private String s_question,l_Id;
        private Button post;
        private TextView hasNoMeetings,textViewTodayQuote;
        ImageButton editQuote;
        String todayQuote;
        Spinner studentSpinner;
        String selectedStudent, selectedStudentL_Id;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setHasOptionsMenu(true);
            activity = getActivity();
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.dashboard_fragment, container, false);

            someData = activity.getSharedPreferences(filename, 0);

            reminderList = (ListView) view.findViewById(R.id.listReminder);
            upcomingMeetingList = (ListView) view.findViewById(R.id.listMeetings);
            post = (Button) view.findViewById(R.id.post);
            question = (EditText) view.findViewById(R.id.question);
            hasNoMeetings = (TextView) view.findViewById(R.id.textNoMeetings);
            editQuote = (ImageButton) view.findViewById(R.id.editQuote);
            textViewTodayQuote = (TextView) view.findViewById(R.id.todayQuote);
            studentSpinner = (Spinner) view.findViewById(R.id.studentsSpinner);

            l_Id = someData.getString("commonL_Id", "");

            if(Utility.isOnline(activity)){
                new fetchQuote().execute();
            }

            post.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                if(CommonUtils.isNotNull(question.getText().toString())){
                    s_question = question.getText().toString();
                    if(Utility.isOnline(activity)){
                        new PostQuestion().execute();
                    }
                }else{
                    Toast.makeText(activity, "Cannot post blank question", Toast.LENGTH_LONG).show();
                }
                }
            });

            editQuote.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    new MaterialDialog.Builder(activity)
                        .title("Update Quote")
                        .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)
                        .positiveText("Update")
                        .input("Type here", "", false, new MaterialDialog.InputCallback() {
                            @Override
                            public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
                                //showToast("Hello, " + input.toString() + "!");
                                todayQuote = input.toString();

                                new AddQuote().execute();
                            }
                    }).show();
                }
            });

            studentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                    SpinnerWithTag s = (SpinnerWithTag) parent.getItemAtPosition(position);
                    selectedStudent = s.getString();
                    selectedStudentL_Id = s.getTag();
                }

                @Override
                public void onNothingSelected(AdapterView<?> parent) {

                }
            });

            return view;
        }

        class GrabAllStudents extends AsyncTask<String, String, String> {

            JSONArray jsonarray;

            @Override
            protected void onPreExecute() {
                super.onPreExecute();
            }

            @Override
            protected String doInBackground(String... params) {

                List<NameValuePair> para = new ArrayList<NameValuePair>();
                para.add(new BasicNameValuePair("role", "Students"));
                Log.d("request!", "starting");

                JSONObject jsonobject = JSONfunctions.makeHttpRequest(QueryMapper.URL_ALL_STUDENTS, "POST", para);

                try{
                    studentList = new ArrayList<SpinnerWithTag>();
                    studentList.clear();
                    studentList.add(new SpinnerWithTag("Select Student", "0"));
                    studentList.add(new SpinnerWithTag("Select Global", "-1"));

                    jsonarray = jsonobject.getJSONArray("All_Students");

                    for (int i = 0; i < jsonarray.length(); i++) {
                        jsonobject = jsonarray.getJSONObject(i);

                        String studentName = jsonobject.getString("name");
                        String selectedStudentL_Id = jsonobject.getString("l_Id");
                        studentList.add(new SpinnerWithTag(studentName,selectedStudentL_Id));
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                return "Success";
            }

            @Override
            protected void onPostExecute(String sResponse) {

                new GrabAllAdminUpcomingMeetings().execute();
                ArrayAdapter<SpinnerWithTag> adapter = new ArrayAdapter<SpinnerWithTag> (activity, R.layout.spinner_item_result, studentList);

                studentSpinner.setAdapter(adapter);
            }

        }

        class GrabAllUpcomingMeetings extends AsyncTask<String, String, String> {
            int flag = 0;
            JSONArray jsonarray;
            ArrayList<HashMap<String,String>> myAppointmentList;
            MyAppointmentDashboardAdapter myAppointmentAdapter;

            protected void onPreExecute()
            {
                super.onPreExecute();
            }

            protected String doInBackground(String... params)
            {

                List<NameValuePair> para = new ArrayList<NameValuePair>();
                para.add(new BasicNameValuePair("booked_l_Id", l_Id));
                Log.d("request!", "starting");

                JSONObject jsonobject = JSONfunctions.makeHttpRequest(QueryMapper.URL_MY_APPOINTMENT, "POST", para);

                try{
                    myAppointmentList = new ArrayList<HashMap<String,String>>();
                    jsonarray = jsonobject.getJSONArray("My_Appointments");
                    for (int i = 0; i < jsonarray.length(); i++)
                    {
                        HashMap<String, String> map = new HashMap<String, String>();
                        jsonobject = jsonarray.getJSONObject(i);

                        map.put("startTime", jsonobject.getString("startTime"));
                        map.put("endTime", jsonobject.getString("endTime"));
                        map.put("appt_Id", jsonobject.getString("appt_Id"));
                        map.put("l_Id", jsonobject.getString("l_Id"));
                        map.put("m_Id", jsonobject.getString("m_Id"));
                        map.put("date", jsonobject.getString("date"));
                        map.put("booked", jsonobject.getString("booked"));
                        map.put("approved", jsonobject.getString("approved"));
                        map.put("booked_l_Id", jsonobject.getString("booked_l_Id"));
                        map.put("booked_date", jsonobject.getString("booked_date"));
                        map.put("color", Integer.toString(Utility.getRandomColor(activity)));
                        myAppointmentList.add(map);
                    }
                }catch(JSONException e) {
                    e.printStackTrace();
                }
                return null;
            }
            protected void onPostExecute(String file_url) {
                myAppointmentAdapter = new MyAppointmentDashboardAdapter(activity, myAppointmentList);
                upcomingMeetingList.setAdapter(myAppointmentAdapter);
            }
        }

        class GrabAllAdminUpcomingMeetings extends AsyncTask<String, String, String> {
            int flag = 0;
            JSONArray jsonarray;
            ArrayList<HashMap<String,String>> adminAllAppointmentList;
            AdminBookedAppointmentDashboardAdapter AdminAppointmentAdapter;

            protected void onPreExecute()
            {
                super.onPreExecute();
            }

            protected String doInBackground(String... params)
            {

                List<NameValuePair> para = new ArrayList<NameValuePair>();
                Log.d("request!", "starting");

                JSONObject jsonobject = JSONfunctions.makeHttpRequest(QueryMapper.URL_BOOKED_APPOINTMENT_LIST_ADMIN_FRAGMENT, "POST", para);

                try{
                    adminAllAppointmentList = new ArrayList<HashMap<String,String>>();
                    jsonarray = jsonobject.getJSONArray("Admin_Appointment_List");
                    for (int i = 0; i < jsonarray.length(); i++)
                    {
                        HashMap<String, String> map = new HashMap<String, String>();
                        jsonobject = jsonarray.getJSONObject(i);

                        map.put("startTime", jsonobject.getString("startTime"));
                        map.put("endTime", jsonobject.getString("endTime"));
                        map.put("appt_Id", jsonobject.getString("appt_Id"));
                        map.put("l_Id", jsonobject.getString("l_Id"));
                        map.put("m_Id", jsonobject.getString("m_Id"));
                        map.put("date", jsonobject.getString("date"));
                        map.put("booked", jsonobject.getString("booked"));
                        map.put("approved", jsonobject.getString("approved"));
                        map.put("booked_l_Id", jsonobject.getString("booked_l_Id"));
                        map.put("booked_date", jsonobject.getString("booked_date"));
                        map.put("name", jsonobject.getString("name"));
                        map.put("phone", jsonobject.getString("phone"));
                        map.put("emailId", jsonobject.getString("emailId"));
                    }
                }catch(JSONException e) {
                    e.printStackTrace();
                }
                return null;
            }

            protected void onPostExecute(String file_url)
            {
                if(adminAllAppointmentList!=null && adminAllAppointmentList.size()>0){
                    hasNoMeetings.setVisibility(View.GONE);
                }
                AdminAppointmentAdapter = new AdminBookedAppointmentDashboardAdapter(activity, adminAllAppointmentList);
                upcomingMeetingList.setAdapter(AdminAppointmentAdapter);
            }
        }

        class GrabAllReminders extends AsyncTask<String, String, String> {
            int flag = 0;
            JSONArray jsonarray;
            ArrayList<HashMap<String,String>> myRemindersList;
            ReminderAdapter reminderAdapter;

            protected void onPreExecute()
            {
                super.onPreExecute();
            }

            protected String doInBackground(String... params)
            {

                List<NameValuePair> para = new ArrayList<NameValuePair>();
                para.add(new BasicNameValuePair("login_Id", l_Id));
                Log.d("request!", "starting");

                JSONObject jsonobject = JSONfunctions.makeHttpRequest(QueryMapper.URL_GRAB_ALL_REMINDERS, "POST", para);

                try{
                    myRemindersList = new ArrayList<HashMap<String,String>>();
                    jsonarray = jsonobject.getJSONArray("All_Reminders");
                    for (int i = 0; i < jsonarray.length(); i++)
                    {
                        HashMap<String, String> map = new HashMap<String, String>();
                        jsonobject = jsonarray.getJSONObject(i);

                        map.put("r_date", jsonobject.getString("r_date"));
                        map.put("reminder", jsonobject.getString("reminder"));
                        map.put("r_Id", jsonobject.getString("r_Id"));
                        map.put("login_Id", jsonobject.getString("login_Id"));
                        myRemindersList.add(map);
                    }
                }catch(JSONException e) {
                    e.printStackTrace();
                }
                return null;
            }
            protected void onPostExecute(String file_url) {
                reminderAdapter = new ReminderAdapter(activity, myRemindersList);
                reminderList.setAdapter(reminderAdapter);
            }
        }

        class PostQuestion extends AsyncTask<String, String, String> {
            int flag = 0;
            String success="0", message="";

            protected void onPreExecute()
            {
                super.onPreExecute();
            }

            protected String doInBackground(String... params)
            {

                List<NameValuePair> para = new ArrayList<NameValuePair>();
                para.add(new BasicNameValuePair("l_Id", l_Id));
                para.add(new BasicNameValuePair("question", s_question));

                Log.d("request!", "starting");

                JSONObject jsonobject = JSONfunctions.makeHttpRequest(QueryMapper.URL_POST_QUESTION, "POST", para);

                try{
                    success = jsonobject.getString("success");
                    message = jsonobject.getString("message");

                }catch(JSONException e) {
                    e.printStackTrace();
                }
                return null;
            }
            protected void onPostExecute(String file_url) {
                if(!success.equalsIgnoreCase("0") && !success.equalsIgnoreCase("")){
                    question.setText("");
                    Toast.makeText(activity, "Question posted successfully", Toast.LENGTH_LONG).show();
                }else{
                }
            }
        }

        class AddQuote extends AsyncTask<String, String, String> {
            int flag = 0;
            String success="0", message="";

            protected void onPreExecute()
            {
                super.onPreExecute();
            }

            protected String doInBackground(String... params)
            {

                List<NameValuePair> para = new ArrayList<NameValuePair>();
                para.add(new BasicNameValuePair("todayQuote", todayQuote));
                JSONObject jsonobject = JSONfunctions.makeHttpRequest(QueryMapper.URL_ADD_QUOTE, "POST", para);

                try{
                    success = jsonobject.getString("success");
                    message = jsonobject.getString("message");

                }catch(JSONException e) {
                    e.printStackTrace();
                }
                return null;
            }
            protected void onPostExecute(String file_url) {
                if(!success.equalsIgnoreCase("0") && !success.equalsIgnoreCase("")){
                    textViewTodayQuote.setText(todayQuote);
                    Toast.makeText(activity, "Quote Updates", Toast.LENGTH_LONG).show();
                }else{
                    Toast.makeText(activity, "Quote failed to post", Toast.LENGTH_LONG).show();
                }
            }
        }

        class fetchQuote extends AsyncTask<String, String, String> {
            int flag = 0;
            JSONArray jsonarray;
            String success="0", message="";
            String quote;

            protected void onPreExecute()
            {
                super.onPreExecute();
            }

            protected String doInBackground(String... params)
            {
                List<NameValuePair> para = new ArrayList<NameValuePair>();
                para.add(new BasicNameValuePair("todayQuote", todayQuote));
                Log.d("request!", "starting");
                JSONObject jsonobject = JSONfunctions.makeHttpRequest(QueryMapper.URL_FETCH_QUOTE, "POST", para);

                try{
                    jsonarray = jsonobject.getJSONArray("TodaysQuote");
                    for (int i = 0; i < jsonarray.length(); i++) {
                        HashMap<String, String> map = new HashMap<String, String>();
                        jsonobject = jsonarray.getJSONObject(i);

                        quote = jsonobject.getString("quoteText");
                    }
                }catch(JSONException e) {
                    e.printStackTrace();
                }
                return null;
            }
            protected void onPostExecute(String file_url) {
                textViewTodayQuote.setText(quote);

                if(someData.contains("role")) {
                    if (Utility.isOnline(activity)) {
                        new GrabAllReminders().execute();
                        if (someData.getString("role", "").equalsIgnoreCase("Admin")) {
                            editQuote.setVisibility(View.VISIBLE);
                            studentSpinner.setVisibility(View.VISIBLE);
                            new GrabAllStudents().execute();

                        }else{
                            new GrabAllUpcomingMeetings().execute();
                        }
                    }else{
                        Toast.makeText(getActivity(), "Connectivity Issues, You are offline", Toast.LENGTH_LONG).show();
                    }
                }
            }
        }

    }

My PHP file is returning the data properly in the expected manner.

I am confused at the point that, app is not crashing everytime. It crashes occasionally.

When i am using Pay U Money SDKUI in Test environment it is working fine, But when i am using the same SDKUI in the Production environment its giving me the error

I am successfully able to create hash key from my own server, i am not able to understand what i am missing. Please help.

public void onPaymentRelatedDetailsResponse(PayuResponse payuResponse) {
        mPayuResponse = payuResponse;
        findViewById(R.id.progress_bar).setVisibility(View.GONE);
        if(payuResponse.isResponseAvailable() && payuResponse.getResponseStatus().getCode() == PayuErrors.NO_ERROR){ // ok we are good to go
            Toast.makeText(this, payuResponse.getResponseStatus().getResult(), Toast.LENGTH_LONG).show();
            if(payuResponse.isStoredCardsAvailable()){
                findViewById(R.id.linear_layout_stored_card).setVisibility(View.VISIBLE);
            }
            if(payuResponse.isNetBanksAvailable()){ // okay we have net banks now.
                findViewById(R.id.linear_layout_netbanking).setVisibility(View.VISIBLE);
            }
            if(payuResponse.isCashCardAvailable()){ // we have cash card too
                findViewById(R.id.linear_layout_cash_card).setVisibility(View.VISIBLE);
            }
            if(payuResponse.isCreditCardAvailable() || payuResponse.isDebitCardAvailable()){
                findViewById(R.id.linear_layout_credit_debit_card).setVisibility(View.VISIBLE);
            }
            if(payuResponse.isEmiAvailable()){
                findViewById(R.id.linear_layout_emi).setVisibility(View.VISIBLE);
            }
            if(payuResponse.isPaisaWalletAvailable() && payuResponse.getPaisaWallet().get(0).getBankCode().contains(PayuConstants.PAYUW)) {
                findViewById(R.id.linear_layout_payumoney).setVisibility(View.VISIBLE);
            }
        }else{
            Toast.makeText(this, "Something went wrong : " + payuResponse.getResponseStatus().getResult(), Toast.LENGTH_LONG).show();
        }

        // no mater what response i get just show this button, so that we can go further.
        findViewById(R.id.linear_layout_verify_api).setVisibility(View.VISIBLE);
    }

I am getting the response

status = "ERROR"
result = "Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject"
code = 5014 

I've recently installed Visual Studio with Xamarin.

When I want to run even not modified app, I'm getting error

java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

Screenshoot of SDK manager: SDK manager

From android 7.0 (API 24) theres nothing installed.

When I remove this Android SDK Build tools 24.0.3 I get just "Deploy failed" without any error information.

Seems like Visual Studio is still trying to use the 24 API version. Should I switch to API version 23? If yes, how can I do it?

How can I set theme for BottomSheetDialogFragment?

Unfortunatelly setting dialogTheme in Activity theme is not working, and I have standard accent color instead of mine.

I'm working on integration of Google Analytics plugin in Unity project for Android. In editor no problems seem to appear, but when I run my game on the Android device, I receive the following exception (visible in logcat):

java.lang.IllegalArgumentException: Tracker name cannot be empty at com.google.analytics.tracking.android.GoogleAnalytics.getTracker(GoogleAnalytics.java:164) at com.google.analytics.tracking.android.GoogleAnalytics.getTracker(GoogleAnalytics.java:192) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.a(Unknown Source) at com.unity3d.player.UnityPlayer$b.run(Unknown Source) at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in :0 at UnityEngine.AndroidJNISafe.CallObjectMethod (IntPtr obj, IntPtr methodID, UnitEngine.jvalue[] args) [0x00000] in :0 at UnityEngine.AndroidJavaObkject._Call[AndroidJavaObject] (System.String methodName, System.Object[] args) [0x00000] in :0 at UnityEngine.AndroidJavaObkject.Call[AndroidJavaObject] (System.String methodName, System.Object[] args) [0x00000] in :0

I got all the prefab fields filled in, there should be no empty names. What did I miss?

I'm using:

  • Google Analytics plugin v3
  • Unity v.5.3.6f1 on Mac OS Sierra v.10.12
  • Android SDK has been recently updated
  • Device is: ASUS TF201 with Android 4.1.1

I'm developing an Android app on Android Studio and I'm calling a method from API level 19. My build.gradle looks like this:

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.2'

    productFlavors {
        // Define separate dev and prod product flavors.
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 21
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 16
        }
    }

    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 16
        multiDexEnabled true
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
}

I have no lint.xml files in my project, so no lint checks are overriden.

The problem is that the lint check "Calling new methods on older versions." doesn't find the method call for API level 19. If I open the build variants panel and select prodDebug or prodRelease the method gets underlined in red, but the project builds well. How can I get Android Studio to effectively show the aforementioned method in the analyze result or to block me from correctly building the project?

i am send notification with onesignal api

String strJsonBody = "{"
                              +   "\"app_id\": \"" + APP_ID + "\","
                              +   "\"included_segments\": [\"All\"],"
                              +   "\"filters\": [{\"field\": \"tag \", \"key \": \"" + key + " \", \"relation \": \"=\", \"value\": \"1\"}],"
                              +   "\"data\": {\"news_id\": \"" + newsId + "\"},"
                              +   "\"contents\": {\"en\": \"" + newsTitle + "\"}"
                              + "}";

and get error {"errors":[" tag is not a valid filter field."]}

I have LinkdIn Client Id and it was woking perfect on Android app.But currently i got the

The Client Id - 77#####3ey disable error.

Que.1 Do i need to create new application on linked in developer account?.

Que.2 Is there any way to enable Client ID?.

Please advice me.Thank you in advance.

I want to create dialog AlertDialog. The header does not padding bottom. The header and footer are no borders.

How can I get to be in dialoge borders and the correct spacing of the header? Example: https://developer.android.com/guide/topics/ui/dialogs.html

  • I use theme Theme.AppCompat.NoActionBar
  • minSdkVersion 18
  • compileSdkVersion 24
  • targetSdkVersion 24
  • AppCompatActivity

Code:

AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {

    }
});

builder.setTitle("Title");
builder.setView(R.layout.dialog_www);

AlertDialog dialog = builder.create();
dialog.show();

the dialog_www layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        >

        <Button
            android:text="Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/button2"
            android:layout_weight="1" />

        <Button
            android:text="Button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/button4"
            android:layout_weight="1" />

    </LinearLayout>
</RelativeLayout>

The result is: screenshot

Thanks!

i have mainlayout.xml as coded below :

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    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:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layoutDirection="rtl"
    tools:context="com.sanwix.mh.meeting.MainActivity">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <include
            android:id="@+id/toolbar"
            layout="@layout/layout_appbar"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/MyMainReycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/toolbar"
            android:padding="16dp">

        </android.support.v7.widget.RecyclerView>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/Fabb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_gravity="left|bottom"
            android:layout_margin="16dp"
            android:src="@android:drawable/ic_menu_edit"
            android:transitionName="sharedFab"
            app:backgroundTint="@color/colorAccent"
            app:elevation="8dp"
            app:fabSize="normal"
            />

    </RelativeLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/myRecycleDrawer"
        android:layout_width="280dp"
        android:fitsSystemWindows="true"
        android:layout_gravity="start"
        android:layout_height="match_parent"/>

</android.support.v4.widget.DrawerLayout>

every things work prefectly on pre-lolipop devices. but on lolipop or above , it doesnt run prefectly. my issue is that : i have no main content for myactivity and each one of my elements take a seperate drawer . i mean the RelativeLayout will be shown as left-side drawer and the RecyclerView will be shown as right-side drawe on lolipop or above. but what i want is just one drawer on rightside(my recycle)

any idea will be appreciated

the exception was: UnsupportedMethodException Unsupported method: AndroidProject.getPluginGeneration(). The version of Gradle you connect to does not support that method. To resolve the problem you can change/upgrade the target version of Gradle you connect to. Alternatively, you can ignore this exception and read other information from the model.

Let us using the following code as an example. relativelayoutChild expands to the outside of relativeLayoutParent due to layout_margin="-30dp".

<RelativeLayout
    android:id="@+id/relativeLayoutParent"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:id="@+id/relativelayoutChild"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="-30dp">
    </RelativeLayout>
</RelativeLayout>  

Is there a way to prevent this? In case you wonder why I am asking this, I use negative margin as a convenient way to zoom in the content.

The game I play on android has a very important file and all the images stored in firebase..Now how can I access it?..How is it possible for the game to download files from firebase once the game starts?..Could it like be detected by Wireshark?

Thanks!

I’m having an issue with iOS app I’m testing right now (using XCUITest). It has a screen with 20 elements which executes a loadMore() function (if indexPath.row == model.rowsCount - 10) (which adds another 20 elements to the bottom of the app screen) while scrolling down and there are 10 items left to the bottom of that list. It looks that getting view hierarchy for example, causes that screen to load another 20 elements which I want to avoid. Anyone had similar issue? How to prevent loadMore() from executing while getting view hierarchy?

Cheers.

What are the requirements and guidelines to develop a third-party Carplay app? How can I get them?

thanks in advance.

how to use pmcmd command in UNIX script. am not able to execute directly in shell script it is not executing.

I have this Fragment

import android.app.ProgressDialog;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.JsonReader;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.TabHost;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;

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

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
public class ClasesFragment extends Fragment {

    private static int NUM_PAGES = 13;
    private ViewPager mPager;
    private PagerAdapter mPagerAdapter;
    private ProgressDialog pDialog;
    private JsonReader reader;
    protected TableLayout MainLayoutDatos;
    protected View view;

    private TableRow[] datosTableRows;

    private String razon = "";
    boolean success = false;

    private ArrayList<String> nombresEstaciones = new ArrayList<String>();
    private ArrayList<ArrayList<Number>> aDatosVolList = new ArrayList<ArrayList<Number>>();
    private ArrayList<ArrayList<Number>> aDatosNivelList = new ArrayList<ArrayList<Number>>();
    private ArrayList<ArrayList<Number>> aFechasList = new ArrayList<ArrayList<Number>>();
    public ProgressDialog pdLoading;

    public ClasesFragment() {
        // Required empty public constructor
    }

    static String convertStreamToString(java.io.InputStream is) {
        java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
        return s.hasNext() ? s.next() : "";
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_clases, container, false);
        TabHost tabhost = (TabHost) view.findViewById(R.id.tabHostClases);
        tabhost.setup();
        TabHost.TabSpec spec1 = tabhost.newTabSpec("DATOS");
        TabHost.TabSpec spec2 = tabhost.newTabSpec("GRÁFICOS");
        spec1.setIndicator("DATOS");
        spec1.setContent(R.id.pestanaDatosEmb);
        spec2.setIndicator("GRÁFICOS");
        spec2.setContent(R.id.pestanaGrafEmb);
        tabhost.addTab(spec1);
        tabhost.addTab(spec2);

        HorizontalScrollView pestanaDatos = (HorizontalScrollView) view.findViewById(R.id.pestanaDatosEmb);
        //Create the layout para pestanaDatosEmb
        MainLayoutDatos = new TableLayout(view.getContext());
        MainLayoutDatos.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT));
        MainLayoutDatos.setStretchAllColumns(true);
        pestanaDatos.addView(MainLayoutDatos);

        NUM_PAGES = 5;
        mPager = (ViewPager) view.findViewById(R.id.pager);
        mPagerAdapter = new ScreenSlidePagerAdapter(getActivity().getSupportFragmentManager());
        mPager.setAdapter(mPagerAdapter);

        pdLoading = new ProgressDialog(getActivity());

        try {
            ConnectivityManager connMgr = (ConnectivityManager)
                    getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

            if (networkInfo != null && networkInfo.isConnected()) {
                new JsonTask().execute(new URL("http://www.myhost.com/android/clases"));
           } else {
                Toast.makeText(getActivity(), "Error de conexión", Toast.LENGTH_LONG).show();
           }

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

        return view;
    }

    public class JsonTask extends AsyncTask<URL, Void, String> {

        @Override
        protected String doInBackground(URL... urls) {
            String resultado = "";
            HttpURLConnection con = null;
            try {
                // Establecer la conexión
                con = (HttpURLConnection) urls[0].openConnection();
                con.setConnectTimeout(15000);
                con.setReadTimeout(10000);

                int statusCode = con.getResponseCode();

                if (statusCode != 200) {
                    System.out.println("ERROR ESTATUS CODE: " + String.valueOf(statusCode));
                } else {
                    // Parsear el flujo con formato JSON
                    InputStream in = new BufferedInputStream(con.getInputStream());
                    resultado = convertStreamToString(in);
                }

            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (con != null) {
                    con.disconnect();
                }
            }

            return resultado;
        }

        protected void onPreExecute() {
            pdLoading.setMessage("\tCargando información...");
            pdLoading.show();
        }

        @Override
        protected void onPostExecute(String resultado) {
            pdLoading.dismiss();
            try {
                JSONObject respuesta = new JSONObject(resultado);
                JSONArray datos = respuesta.getJSONArray("datos");

                for(int i=0;i<datos.length();i++){

                    JSONObject clase = datos.getJSONObject(i);

                    TableRow row = new TableRow(view.getContext());
                    TextView text = new TextView(view.getContext());  text.setText(clase.getString("one"));  text.setPadding(4,2,4,2);
                    TextView text2 = new TextView(view.getContext()); text2.setText(clase.getString("two")); text2.setPadding(4,2,4,2);
                    TextView text3 = new TextView(view.getContext()); text3.setText(clase.getString("three"));    text3.setPadding(4,2,4,2);
                    TextView text4 = new TextView(view.getContext()); text4.setText(clase.getString("four"));     text4.setPadding(4,2,4,2);
                    TextView text5 = new TextView(view.getContext()); text5.setText(clase.getString("five")); text5.setPadding(4,2,4,2);
                    TextView text6 = new TextView(view.getContext()); text6.setText(clase.getString("six")); text6.setPadding(4,2,4,2);
                    TextView text7 = new TextView(view.getContext()); text7.setText(clase.getString("seven")); text7.setPadding(4,2,4,2);
                    TextView text8 = new TextView(view.getContext()); text8.setText(clase.getString("eight")); text8.setPadding(4,2,4,2);
                    TextView text9 = new TextView(view.getContext()); text9.setText(clase.getString("nine")); text9.setPadding(4,2,4,2);
                    TextView text0 = new TextView(view.getContext()); text0.setText(clase.getString("ten")); text0.setPadding(4,2,4,2);
                    row.addView(text);
                    row.addView(text2);
                    row.addView(text3);
                    row.addView(text4);
                    row.addView(text5);
                    row.addView(text6);
                    row.addView(text7);
                    row.addView(text8);
                    row.addView(text9);
                    row.addView(text0);

                    MainLayoutDatos.addView(row);
                }

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


    private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
        public ScreenSlidePagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return ScreenSlidePageFragment.create(position);
        }

        @Override
        public int getCount() {
            return NUM_PAGES;
        }
    }

}

this class inflate the next XML "R.layout.fragment_clases"

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="es.redhidrosurmedioambiente.saihredhidrosur.EmbalsesFragment"
    android:baselineAligned="false">


    <TabHost
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tabHostEmbalses"
        android:layout_gravity="center_horizontal">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:clickable="true"
                android:tabStripEnabled="true"></TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <HorizontalScrollView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/pestanaDatosEmb" />

                <ScrollView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/pestanaGrafEmb">

                    <android.support.v4.view.ViewPager
                        xmlns:android="http://schemas.android.com/apk/res/android"
                        android:id="@+id/pager"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />

                </ScrollView>

            </FrameLayout>
        </LinearLayout>
    </TabHost>


</LinearLayout>

this layout has 2 tabs, the first work correctly, it show me a table with my information, the second i tried put a viewpager. The problem is the viewpager doesn't work, when i change to second tab, there is no errors but it not show nothing. I think i followed all the steps in some informations that i found in google here https://developer.android.com/training/animation/screen-slide.html For more information i put my ScreenSliderPageFragment:

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class ScreenSlidePageFragment extends Fragment {
    /**
     * The argument key for the page number this fragment represents.
     */
    public static final String ARG_PAGE = "page";

    /**
     * The fragment's page number, which is set to the argument value for {@link #ARG_PAGE}.
     */
    private int mPageNumber;

    /**
     * Factory method for this fragment class. Constructs a new fragment for the given page number.
     */
    public static ScreenSlidePageFragment create(int pageNumber) {
        ScreenSlidePageFragment fragment = new ScreenSlidePageFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_PAGE, pageNumber);
        fragment.setArguments(args);
        return fragment;
    }

    public ScreenSlidePageFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPageNumber = getArguments().getInt(ARG_PAGE);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout containing a title and body text.
        ViewGroup rootView = (ViewGroup) inflater
                .inflate(R.layout.test, container, false);

        return rootView;
    }

    /**
     * Returns the page number represented by this fragment object.
     */
    public int getPageNumber() {
        return mPageNumber;
    }
}

and i put the layout file that i use for the content of a fragment "R.layout.test"

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/content"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView style="?android:textAppearanceMedium"
        android:padding="16dp"
        android:lineSpacingMultiplier="1.2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/testString" />
</ScrollView>

What i need to do for this viewpager works?

I'm playing with rxjava and found there is a risk of memory leak if a subscription is not completed before an activity is destroyed because "observables retain a reference to the context". One of the demos for such case is given as below, if the subscription is not unsubscribed onDestroyed (source: https://github.com/dlew/android-subscription-leaks/blob/master/app/src/main/java/net/danlew/rxsubscriptions/LeakingActivity.java):

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_leaking);

    // This is a hot Observable that never ends;
    // thus LeakingActivity can never be reclaimed
    mSubscription = Observable.interval(1, TimeUnit.SECONDS)
        .subscribe(new Action1<Long>() {
            @Override public void call(Long aLong) {
                Timber.d("LeakingActivity received: " + aLong);
            }
        });
}

However I'm not sure why such a leak exists. I've checked the Observable class and seen nothing relevant to Context. So all I can think of is because there is an anonymous Action1 class defined within the subscribe method which hold a reference to the activity instance. And the observable in turn holds a reference to the action. Am I right?

Thanks