I have a ListUser.java class with a datatable, displaying UserData information, displays 4 columns, the last column is an AbstractColumn that has on it's populateItm method has added a inner class LinkedPanel that fills the column with buttons, one of these buttons is an Link,Model... this link has a @Override onClick() method, that calls a Injected userDataDAO, using the Model, I obtain the UserData object, I update this object and pass it directly to the userDataDAO and merge the object into database, without using any form, is updating directlly safe? (or a good practice)


ListUsers.java is a List that has a LinkPanel that displays buttons on the last column of the

List<IColumn<UserData, String>> cols = new ArrayList<>(4);
    cols.add(new PropertyColumn<UserData, String>(new Model<>("Usuario"),"username"));
    cols.add(new PropertyColumn<UserData, String>(new Model<>("Creacion"),"dateCreation"));
    cols.add(new PropertyColumn<UserData, String>(new Model<>("Ultimo Ingreso"),"lastLogin"));
cols.add(new AbstractColumn<UserData, String>(new Model<>("Operación"), "Desactivar") {

        @Override
        public void populateItem(final Item<ICellPopulator<UserData>> item, String string, final IModel<UserData> imodel) {
item.add( new LinkPanel(string, imodel, "deshabilitar")
            );
        }
    });

ListUsers.html
...
  <table class="table table-hover table-condensed table-responsive" wicket:id="users"></table>
...

public class LinkPanel extends Panel {

    public LinkPanel(String id, final IModel<UserData> imodel, String label) {
        super(id, imodel);
        add(
                //Boton habilitar/deshabilitar
                new Link<UserData>("deshabilitar", imodel) {
                    @Override
                    public void onClick() {

                        usData.setEnabled(!usData.isEnabled());
                        userDAO.edit(usData);
                        imodel.setObject(usData);
                        getSession().info(Msg.OPERATION_SUCCESSFUL);
                    }
...

I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one other. I know there is no 1 to 1 match between SOLID principles and OOP Design patterns, but I want to introduce the students a pattern that is sort of inclusive of all the SOLID design principles at play.

Any ideas?

I'm really trying to fit in the observer pattern but want to keep it conforming with all the SOLID principles.

I have a MyObject which has an x and y coordinate.

as far as I can see, I can store it in three ways:

class MyObject:
    def __init__(self, x, y):
        self.x = x
        self.y = y

class MyObject:
    def __init__(self, x, y):
        self.position = [x, y]

class MyObject:
    def __init__(self, x, y):
        self.position = Coord(x,y) #Coord class created elsewhere

Is there a best practise either way for this ?

Where I'm thinking this is relevant, is when passing these coordinates into other methods:

eg.

myObj = MyObject(0,0)
searchLocation(myObj.x, myObj.y)
searchLocation2(myObj.position)

I'm currently working on designing a small web application (MVC5) and I'm to the point of designing my database. I have the schema I want worked out and I am quite proficient in SQL Server. (I have my SQL 2012 MCSA.) I'm going to be using entity framework 6 as my ORM. I've been quite interested in the code-first approach because I'm not a big fan of designers and I like to be able to see and work with the code myself.

Because my SQL skills are quite strong I am inclined to create the schema myself and write my own CREATE TABLE queries, etc. I feel like that gives me a lot more control over constraint and index creation.

But I haven't really worked much with entity framework in the past so there may be some benefits to this that I'm missing. I know you can do code-first against an existing database in EF6 anyway, so that would be another option.

I've tried googling around a bit and reading MSDN but most of the benefits seems to be that you don't need to worry about the SQL. Since that isn't a concern of mine I'm failing to see the benefit of allowing entity framework to create my schema.

Are there any benefits to allowing entity framework to create my database that I'm missing?

I have a World

class World:
    def __init__(self):
        self.size = 10
        self.n_busStops = 10

        busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0)
        self.buses = [Bus([0,1,2,3,4,5,6,7,8,9])]

Now each of the buses are going to move around the world, dropping off and picking up passengers.

The bus contains information about it's route. When it gets to it's next stop, it needs to query the busStopMatrix to find out how many passengers there are there, and how far away the next stop on its route is.

Is it a good idea for an object to query it's parent like this? If so, what is this design pattern called?

Something like:

class World:
    def __init__(self):
        self.size = 10
        self.n_busStops = 10

        busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0)
        self.buses = [Bus([0,1,2,3,4,5,6,7,8,9], owner =self)]

class Bus:
    def __init__(self, route, parent):
        self.route = route
        self.currentStop = route[0]
        self.parent = parent
    def move(self): 
        ifAtDestination():
            pickUpPassengers(self.parent.getPassengersAtStop(currentStop))

I otherwise can't think how the Bus can get information about the world it's in. The alternative I can think of is that the route is made up of references directly to the BusStops, so it can directly query them.

eg.

class World:
    def __init__(self):
        self.size = 10
        self.n_busStops = 10

        busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0)
        self.buses = [Bus([busStopmatrix.getAllStops()])]

class Bus:
    def __init__(self, route):
        self.route = route
        self.currentStop = route[0]

    def move(self): 
        ifAtDestination():
            pickUpPassengers(currentBusStop)

According to one page on code.google.com, "left recursion" is defined as follows:

Left recursion just refers to any recursive nonterminal that, when it produces a sentential form containing itself, that new copy of itself appears on the left of the production rule.

Wikipedia offers two different definitions:

  1. In terms of context-free grammar, a non-terminal r is left-recursive if the left-most symbol in any of r’s productions (‘alternatives’) either immediately (direct/immediate left-recursive) or through some other non-terminal definitions (indirect/hidden left-recursive) rewrites to r again.

  2. "A grammar is left-recursive if we can find some non-terminal A which will eventually derive a sentential form with itself as the left-symbol."

I'm just barely starting out with language creation here, and I'm doing it in my spare time. However when it comes down to selecting a language parser, whether left recursion is supported by this parser or that parser is an issue that immediately comes up front and center. Looking up terms like "sentential form" only leads to further lists of jargon, but the distinction of "left" recursion almost has to be something very simple. Translation please?

So I have a small setup file that needs to install a few run-time files. The files are located within sub directories of the root of the drive. The drive letter will be different on every customers machine, so I was trying this and several other methods to no avail.

            // File is being ran from D:\ "eg: D:\setup.exe"
            // All my runtimes are in the Tools\Runtime direcorties
            string path = Directory.GetCurrentDirectory();
            string ext = "/q /norestart";
            string location = "\\Tools\\Runtimes\\Net\\";
            string step1 = "dotnetfx35.exe";
            var process = Process.Start(path + location + step1 + ext);
            process.WaitForExit();

As you pros and more experienced programmers know, for some reason... It doesn't work I keep getting file not found.

Semi-new to programming Android apps, or apps in general. I'm trying to create a bunch of buttons based on JSON response. The response is coming back good (checked in Log.i) and no errors showing an issue, but the buttons aren't displaying. Here's my main activity, asynctask class and main xml. Any feedback super appreciated.

Main Activity:

package com.example.tapmap;

import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;

import android.support.v7.app.ActionBarActivity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;


public class MainActivity extends ActionBarActivity {
    Spinner spinner;
    public SpinAdapter adapter;
    JSONObject jsonobject;
    JSONArray jsonarray;
    ProgressDialog mProgressDialog;
    ArrayList<String> barlist;
    Brewery[] breweries;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        spinner = (Spinner) findViewById(R.id.planets_spinner);
        Log.i("msg", "sent to json");
        new DownloadJSON().execute();
        Log.i("msg", "past to json");
    }

    private class DownloadJSON extends AsyncTask<Void, Void, Void> 
    {

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

        barlist = new ArrayList<String>();
        try
        {
            Log.i("msg", "inside try");
            HttpClient httpclient = new DefaultHttpClient();
            httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
            HttpGet request = new HttpGet("http://fltapmap.com/populate.php");
            HttpResponse response = httpclient.execute(request);
            HttpEntity resEntity = response.getEntity();

            String _response=EntityUtils.toString(resEntity); 
            jsonobject = new JSONObject(_response); 
            jsonarray = jsonobject.getJSONArray("breweries");
            Log.i("msg", "breweries lengths: "+jsonarray.length());
            breweries = new Brewery[jsonarray.length()];
            for (int i = 0; i < jsonarray.length(); i++) {
                jsonobject = jsonarray.getJSONObject(i);
                breweries[i] = new Brewery();
                breweries[i].setId(jsonobject.optInt("ID"));
                breweries[i].setName(jsonobject.optString("brewery"));
            }
        }catch(Exception e)
        {
            Log.i("msg",""+e.getMessage());

        }
        return null;

        }
        protected void onPostExecute(Void args) {
            // Spinner adapter
            adapter = new SpinAdapter(MainActivity.this,android.R.layout.simple_spinner_item,breweries);
            spinner.setAdapter(adapter);

            // You can create an anonymous listener to handle the event when is selected an spinner item
            spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view,
                        int position, long id) {
                    // Here you get the current item (a User object) that is selected by its position
                    Brewery brewery = adapter.getItem(position);
                    // Here you can do the action you want to...
                    Log.i("msg", "inside selected method"+String.valueOf(brewery.getId()));

                    new RetrieveBeersTask(MainActivity.this, findViewById(R.id.beer_list)).execute(String.valueOf(brewery.getId()));
                    /*
                    jsonarray = jsonobject.getJSONArray("ontap");
                    Log.i("msg", "breweries lengths: "+jsonarray.length());
                    Button beer_btns[] = new Button[jsonarray.length()];
                    Log.i("msg","buttons made");

                    for (int i = 0; i < jsonarray.length(); i++) {
                        Log.i("msg","in loop"+String.valueOf(i));
                        LinearLayout layout = (LinearLayout)findViewById(R.id.beer_list);

                        beer_btns[i] = new Button(MainActivity.this);

                        beer_btns[i].setText(jsonarray.getJSONObject(i).getString("beer"));

                        beer_btns[i].setGravity(Gravity.CENTER_HORIZONTAL);

                        beer_btns[i].setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                //add your code here 
                            }
                        });
                        layout.addView(beer_btns[i]);
                    }
                    */
                }
                @Override
                public void onNothingSelected(AdapterView<?> adapter) {  }
            });
        }
   }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

AsyncTask Class

package com.example.tapmap;

import java.util.ArrayList;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;

import android.app.Activity;
import android.os.AsyncTask;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class RetrieveBeersTask extends AsyncTask<String, Void, ArrayList<String>> {

    private Exception exception;
    JSONObject jsonobject;
    public JSONArray jsonarray;
    public ArrayList<String> return_beers;
    private Activity myMain;
    private View myLayout;

    public RetrieveBeersTask(Activity passedin, View mainLayout) {
        this.myMain = passedin;
        this.myLayout = mainLayout;
    }

    @Override
    protected ArrayList<String> doInBackground(String... brewery) {
        try {
            Log.i("msg", "inside launcher: Brewery - "+brewery[0]);
            HttpClient httpclient = new DefaultHttpClient();
            httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
            HttpGet request = new HttpGet("http://fltapmap.com/ontap.php?id="+brewery[0]);
            HttpResponse response = httpclient.execute(request);
            Log.i("msg","request back");
            HttpEntity resEntity = response.getEntity();
            String _response=EntityUtils.toString(resEntity);

            /*
            Log.i("msg","ssending request");
            HttpResponse response = httpclient.execute(request);
            Log.i("msg","request back");
            HttpEntity resEntity = response.getEntity();
            Log.i("msg","should have response");
            String _response=EntityUtils.toString(resEntity);
            Log.i("msg","got repsonse"+_response);
            */
            jsonobject = new JSONObject(_response); 
            jsonarray = jsonobject.getJSONArray("ontap");

            return_beers = new ArrayList<String>();
            for (int i = 0; i < jsonarray.length(); i++) {
                Log.i("msg", "beer name: "+jsonarray.getJSONObject(i).getString("beer"));
                return_beers.add(jsonarray.getJSONObject(i).getString("beer"));
            }
            return return_beers;        
        } catch(Exception e) {
            e.printStackTrace();
            return null;        
        }            
    }

    protected void onPostExecute(ArrayList<String> beers) {
        // TODO: check this.exception 
        // TODO: do something with the feed
        Log.i("msg", "length of array: "+String.valueOf(beers.size()));
        Button beer_btns[] = new Button[jsonarray.length()];
        for (int i = 0; i < beers.size(); i++) {

            beer_btns[i] = new Button(myMain);

            beer_btns[i].setText(beers.get(i));

            beer_btns[i].setGravity(Gravity.CENTER_HORIZONTAL);

            beer_btns[i].setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //add your code here 
                }
            });
            LinearLayout layout = (LinearLayout)myLayout;
            Log.i("msg",String.valueOf(layout));
            layout.addView(beer_btns[i]);
        }
    }
}

I'm still not entirely clear on when Android leaks Bitmaps, so, I'm curious if anyone knows...

Is it safer, in my Extended View, in which I'm loading Bitmaps from disk and setting them as Drawable, to designate the variable as a View level Bitmap that I call recycle() on in the onDetachedFromWindow() callback, or is it ok to just make it a local variable inside the method that loads the Bitmap and sets it as the Drawable?

I'm using the global approach now and seeing the error intermittently, which makes me think that perhaps there are ways to get out of the Activity with onDetachedFromWindow() having never been called?

very curious.

I have been testing this app on simulators and my test Android phone but some people are seeing the navigation drawer below go above the actionbar to the top cutting off two menu items. Does anyone know what I should look for on how to fix this since I cant replicate it myself? I was able to replicate this in version 4.4.2 but not anything below it in the simulator.

enter image description here

Is there a way to intercept an http request on Windows Phone 8?

I have a PhoneGap application that I would like to intercept some of the http requests that the WebView is making and return my own responses. I am intercepting calls that are requesting assets on a web server and returning assets that are available to be generated locally.

In Android I can use shouldInterceptrequest

In iOS I can use NSURLProtocol

From what I can tell on Windows Phone 8 I can register my own scheme to launch my app but I cannot intercept http requests. Is there something that I am missing?

Good Day, my onkeyDown method does not working in fragment. What is the reason on this?Please help me ASAP. Here's my code. I am a newbie on Fragment, I got stuck on this. Please help me. ASAP. What I need to do here is that when I clicked the menu button supposed to be the soft keyboard will be hide but it is not working. Please help me.

public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ( keyCode == KeyEvent.KEYCODE_MENU ) {
            //Cast the Axle Distance TextBox 
            EditText length = (EditText) getView().findViewById(R.id.txtLength);

            //Hide the keyboard when Help Dialog Show 
            InputMethodManager inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(length.getWindowToken(), 0);
            return true;
        }
        return false;
    }

I recently got into Android development and I'm a bit confused about how the savedInstanceState works. Lets say I was making a game and I want to save the players score, would I be able to save it during onSavedInstanceState() to the savedInstanceState Bundle and always be able to retrieve the score from it no matter whether the device was shut off or the user just completely closed the app?

i`m creating a project that i run in 2 device,

  1. nexus 7
  2. samsung galaxy tab p-3100

as we know to make a dimens about the width, height and anything else in different resolution, we use dimens.xml inside the value folder.

i used dimens.xml inside ldpi folder, but when i run the application something weird... here`s the case

========================= ---> i create a edittext that contain text of date --> 17-08-2014 i made the width 125dp in ldpi dimens value. when i run the application, in nexus everything run but when i run samsung, the edittext width not enough for the date, so number 4 in 2014 goes down...

first maybe i thing i must write the width for samsung in mdpi, but nothing change. samsung device still get width value from ldpi...

folder that i use to write dimens.xml is values, values-large, values-ldpi, values-mdpi, values-v11, values-v14.

my question : where i should put my dimens xml? or any other values folder i have to create???

thank you

Good evening, i have two activities, MainActivity (ListActivity) and ColorChanger(ActionBarActivity). I'm tried to have MainActivity as my launcher activity but as soon as my application start, it jumps automatically to ColorChanger.

Here's my activity tag in AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".ColorChanger"
        android:label="@string/title_activity_color_changer">
    </activity>
</application>

My ColorChanger activity is as default, i just created an activity and didn't changed anything on it, while my MainActivity contains the following:

public class MainActivity extends ListActivity {

    ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
            //listView = (ListView)findViewById(R.id.list);
        String[] str = new String[]{"Escolher cores"};
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, str);
        setListAdapter(adapter);
    }

    protected void onListItemClick(ListView l, View v, int position, long id){
        super.onListItemClick(l, v, position, id);
        Intent intent = null;
        switch(position){
            case 0: intent = new Intent(this, ColorChanger.class);
        }
        startActivity(intent);
    }
}

What am i doing wrong?

When i scale zoom the up quick and fast then will crash around 5-10 second.

private int getTrueHeight(){
    Window window= container.getWindow();
    window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
    Log.d(TAG, "True Height is "+ rectgle.height());
    return rectgle.height();

    //return container.getWindowManager().getDefaultDisplay().getHeight()-StatusBarHeight;
}

this is the code when scale then call it.

Please give me some advise. Thanks.

I have a screen that shows user's information in a 3 listview columnn, I get the data for each listview from 3 arraylist, each arraylist contains data from xml that I parsed using DOM parser. for the first listview, I want the user to be able to click on it, get the value of the listview item(its a string), and get navigated to another screen based on the value of the single item selected. E.G. the arraylist will contain ( A,B,C,D,...), so the listview will have ( A,B,C,D), if the user clicked on B> the user should be navigated to screen B(I'm gonna have a query that uses the value of that list item)

ViewMyTickets.java

    public class ViewMyTickets extends ListActivity  {


        public static String buttonText;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_view_my_tickets);


        string theirID = xmlresult// this is the xml result i get from web services


try {
    DocumentBuilderFactory dbf =
        DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource is = new InputSource();
    is.setCharacterStream(new StringReader(theirID));

    Document doc = db.parse(is);

    //All the UDSObjects
    NodeList nodesUDSObjectList = doc.getElementsByTagName("UDSObject");
    // iterate the UDSObjects
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> valSetOne = new ArrayList<String>();
    List<String> valSetTwo = new ArrayList<String>();
    List<String> valSetThree = new ArrayList<String>();
    for (int i = 0; i < nodesUDSObjectList.getLength(); i++) {
       Element elementUDSObject = (Element) nodesUDSObjectList.item(i);
       //You have a UDSObjects now
       NodeList nodesAttributeList = elementUDSObject.getElementsByTagName("Attribute");
       //You have a list of the attributes for UDSObject(i)
       // iterate the Attributes of the elementUDSObject(i)
        for (int iA = 0; iA < nodesAttributeList.getLength(); iA++) {
            Element elementAttribute = (Element) nodesAttributeList.item(iA);
            //You have attribute(iA)
            NodeList AttrNameElementList = (NodeList) elementAttribute.getElementsByTagName("AttrName");
            String nameValue = getCharacterDataFromElement((Element)(AttrNameElementList.item(0)));

            System.out.println("name"+nameValue);
            NodeList AttrValueElementList = (NodeList) elementAttribute.getElementsByTagName("AttrValue");
            String valueValue = getCharacterDataFromElement((Element)(AttrValueElementList.item(0)));
            System.out.println("value"+valueValue);
            if(nameValue.equals("ref_num")){
                valSetOne.add(valueValue);
            }
            if(nameValue.equals("summary")){
                valSetTwo.add(valueValue);
            }
            if(nameValue.equals("customer.combo_name2")){
                valSetThree.add(valueValue);
            }


        }
    }
    map.put("ref_num", valSetOne);
    map.put("summary",valSetTwo);
    map.put("customer",valSetThree);




 ListView myListView = (ListView) findViewById(R.id.listviewrequest);
 myListView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, valSetOne));

 myListView.setOnItemClickListener(new OnItemClickListener() {

     @Override
     public void onItemClick(AdapterView<?> parent, View view,
             int position, long id) {
         // getting values from selected ListItem
         String name = ((Button) view.findViewById(R.id.requestnumberbutton)).getText().toString();

         // Starting new intent
         Intent in = new Intent(getApplicationContext(), ViewRequest.class);
         in.putExtra("name",name);
         startActivity(in);

     }

 });

 ListView myListView2 = (ListView) findViewById(R.id.listviewrequest2);
 myListView2.setAdapter(new ArrayAdapter<String>(this, R.layout.listview_request2, valSetTwo));


ListView myListView3 = (ListView) findViewById(R.id.listviewrequest3);
myListView3.setAdapter(new ArrayAdapter<String>(this, R.layout.listview_request3, valSetThree));









}

So when i run the application, and click on

E/AndroidRuntime(24691): FATAL EXCEPTION: main
E/AndroidRuntime(24691): Process: com.datacom.studentproject.caservicedesk, PID: 24691
E/AndroidRuntime(24691): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.datacom.studentproject.caservicedesk/com.datacom.studentproject.caservicedesk.ViewMyTickets}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
E/AndroidRuntime(24691):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
E/AndroidRuntime(24691):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
E/AndroidRuntime(24691):    at android.app.ActivityThread.access$800(ActivityThread.java:164)
E/AndroidRuntime(24691):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)

I am getting a Null Pointer Exception in my .java files and I've got no idea what I need to do to fix them.

Here is my logCat showing where the error is getting thrown.:

09-05 11:17:19.569  12588-12588/au.gov.nsw.shellharbour.saferroadsshellharbour E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
        at android.content.ContextWrapper.getSystemService(ContextWrapper.java:370)
        at com.android.internal.app.AlertController$AlertParams.<init>(AlertController.java:801)
        at android.app.AlertDialog$Builder.<init>(AlertDialog.java:273)
        at au.gov.nsw.shellharbour.saferroadsshellharbour.GPSTracker.<init>(GPSTracker.java:116)
        at au.gov.nsw.shellharbour.saferroadsshellharbour.HomeScreen$1.onClick(HomeScreen.java:30)
        at android.view.View.performClick(View.java:2494)
        at android.view.View$PerformClick.run(View.java:9122)
        at android.os.Handler.handleCallback(Handler.java:587)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:130)
        at android.app.ActivityThread.main(ActivityThread.java:3806)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        at dalvik.system.NativeStart.main(Native Method)

I should point out that I'm starting out in android, having done a fair amount in iOS.

Here are my .java files

HomeScreen.java:

public class HomeScreen extends ActionBarActivity {
Button btnShowLocation;

//GPSTracker Class
GPSTracker gps;

@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home_screen);

    btnShowLocation = (Button) findViewById(R.id.btnShowLocation);

    //show location button click event
    btnShowLocation .setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //create class object
            gps = new GPSTracker(HomeScreen.this); //being thrown here (line30)

            if (gps.canGetLocation()){
                double latitude = gps.getLatitude();
                double longitude = gps.getLongitude();

                // \n indicates new line
                Toast.makeText(getApplicationContext(), "your Lcoation is - \nLat: " + latitude + "\nLon: " + longitude, Toast.LENGTH_LONG).show();

            }else{
                //cant get location
                gps.alertDialog.show();
            }
        }
    });

}

GPSTracker.java

public class GPSTracker extends Service implements LocationListener {


private final Context mContext;

//flag for GPS status
boolean isGPSEnabled = false;
//flag for network status
boolean isNetworkEnabled = false;

boolean canGetLocation = false;

Location location;
double latitude; //latitude variable
double longitude; //longitude variable

//The minimum distance to change updates in meters

private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 1;
private static final long MIN_TIME_BW_UPDATES = 1000;

//declare location manager
protected LocationManager locationManager;


public GPSTracker(Context context){
    this.mContext = context;
    getLocation();
}

//function to get latitude
public double getLatitude(){
    if (location != null){
        latitude = location.getLatitude();

    }
    //must have a return (as its a function)
    return latitude;
}

public double  getLongitude(){
    if (location !=null){
        longitude = location.getLongitude();
    }

    return longitude;
}





public Location getLocation() {
    try {
        locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);

        //getting GPS Status
        isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

        //getting Network Status
        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
            //No Network provider is enabled
        }else{
            this.canGetLocation=true;
            //first get location from Network Provider
            if(isNetworkEnabled){
                locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network");
                if (locationManager !=null){
                    location=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if(location !=null){
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();

                    }
                }
            }

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

    }
    return location;
}

//check if this is the best network provider
public boolean canGetLocation(){
    return this.canGetLocation;
}

//show GPs settings in alert box
AlertDialog.Builder alertDialogBuilder = //also being thrown here (line 116)
        new AlertDialog.Builder(this)
                .setTitle("GPS is Settings")
                .setMessage("GPS is not Enabled. Do you want to go to settings menu?")
                .setPositiveButton("Settings", new DialogInterface.OnClickListener() {
                    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        mContext.startActivities(new Intent[]{intent});
                    }
                })
                .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });

// Show the AlertDialog.
AlertDialog alertDialog = alertDialogBuilder.show();

If someone could point out what i am doing wrong, and how to fix it, it would be greatly appreciated.

I have an EditText element in my app that can take in text. I pass the EditText to a function, and in that function I turn it into a string. When the input has too many characters, the string cannot handle the size. Is there any solution/workaround to this? Maybe there's a way to split the EditText into multiple chunks and then convert them into strings?

xml file for my About Screen .. i've done this because my app supports API 9 which does not support DialogFragments, so i am using another class to display another screen instead .. the problem is, i cant seem to scroll through the whole page, my .xml contains nested LinearLayout that also has TextViews .. i tried adding android:scrollbars="vertical" to the main but nothing happens .. i hope someone can help me out, thanks :)

here is my xmlenter link description here

As we know, Android will force kill processes to recycle memory for more important tasks.

So, what will happen to in-flight disk writing when Android kills processes?

For example, my process was unfortunately killed when it was writing a long ArrayList to disk. When my app/process starts again some time in the future, will I get a corrupted storage in which half of the elements of the ArrayList reside? Or is there some mechanism to promise that, say, processes won't be killed when there is some in-flight disk writing ?

Further more, how does Android SharedPreference address this issue?