Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)
<p>i want to ask, why my code doesnt work when running on device, but when i run on emulator android like a Genymotion, it's working perfectly..</p>

<p>someone said on this <a href="https://stackoverflow.com/questions/33068530/errorattempt-to-invoke-virtual-method-java-lang-object-android-content-context">link</a> like this : you cannot call methods on the Activity superclass until after super.onCreate(), except in certain situations. Please postpone your initialization of promptsView until after super.onCreate() has been called.</p>

<p>i still dont get it, please tell me if you have the same problems..</p>

<p>anyway , i'm sorry if my explanation is bad..</p>

<pre><code>public class DestinationListAdapter extends ArrayAdapter&lt;DestinationModel&gt; {

    Context context;
    int layoutResourceId;
    List&lt;DestinationModel&gt; data = Collections.emptyList();

    public DestinationListAdapter(Context context, int layoutResourceId, List&lt;DestinationModel&gt; data) {
        super(context, layoutResourceId, data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View row = convertView;
        DestinationHolder holder = null;

        if(row == null)
        {
            // Predicted Error At Line Below
            LayoutInflater inflater = ((Activity)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new DestinationHolder();
            holder.destination_id = (TextView) row.findViewById(R.id.destination_id);
            holder.destination_name = (TextView) row.findViewById(R.id.destination_name);

            row.setTag(holder);
        }
        else
        {
            holder = (DestinationHolder)row.getTag();
        }

        DestinationModel weather = data.get(position);
        holder.destination_id.setText(weather.getDestination_id());
        holder.destination_name.setText(weather.getDestination_name());

        return row;
    }
</code></pre>