(This question has been asked before, but the last helpful response is from 2013 and is outdated)


My team is currently working on developing an application that will periodically, every 30 min or so, take a users location and store it. The time intervals that we take a users location is not as important as the accuracy of the location. We are trying to balance battery efficiency with location accuracy. One method that we believe will help with battery efficiency is take users location less frequently during non peak use periods. Other than that after reviewing apples best practice documentation it seams like we may be able to use the Significant Location Change Service to activate the Standard Location Service upon significant location change, but I am not sure how accurate this method will be.

What is the best way to periodically take a users location, while conserving battery life?

I have a Core Data app with a single model consisting of several entities. For the purposes of this question, let's call the model "Person" and have the entities "name" (string), "age" (int), "occupation" (string), and "description" (string).

As an example, I may add a new Person. I set their name, age, occupation, and description. I confirm that the context has been updated by checking the contents of the NSManagedObjectContextObjectsDidChangeNotification userInfo. The context is then saved and persisted to disk (confirmed through both logging and querying the SQLite db).

At this point, I can edit any of my Person objects and all entities can be modified, added, deleted, etc., and all changes are confirmed to change the context with NSManagedObjectContextObjectsDidChangeNotification and confirmed to be persisted to disk via logging and querying SQLite - everything works as expected.

However, "occupation" and "description" do not persist after relaunching the app. They are not set as transient (however they are "optional"), and the main context is saved (sometimes several times) after they are set. More so, if I quit the app, before opening it again, I can query the SQLite db and confirm that the changes still exist on disk.

When the app is reopened, I can confirm that all is the same on disk as it was when I quit. However, when I initialize Core Data in my App Delegate, NSManagedObjectContextObjectsDidChangeNotification notifies me that something has changed. For some reason, "occupation" and "description" have disappeared. They haven't been set to null, they've been set to zero-length strings. Therefore, next time something happens that triggers a save, "occupation" and "description" are set to zero-length strings and disappear. This all happens just on launch - I do not access a view controller or anything else that even queries for those specific fields. I do, however, show a view controller that does require a fetch request that populates a UITableView that displays the People objects, although it does not specifically display either of the entities in question.

There is a lightweight Core Data Model migration from Person 1 to Person 2, however, when switching back to Person 1, this problem persists, leading me to believe it is not the migration which is an issue.

I'm asking for recommendations on where to start troubleshooting this issue. I can't post code - I have no idea where in my app the problem is occurring. I've tried to troubleshoot as much as possible with confirming when changes occur in the context and how that compares with what is on disk, I just don't know where to go from here. I don't know why these entities (and only some of them) are disappearing. How would someone start troubleshooting this kind of issue? Any help is appreciated.

I am in a problem. cant figure out why the folowing code wont work . its a simple app that sends a GET request to some php fragment that supposed to insert a row in a table. I cant understand why it doesnt work. please please help.


package com.example.michael.biyum;

import android.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainActivity extends AppCompatActivity {

protected void onCreate(Bundle savedInstanceState) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    final AlertDialog alertDialog = alertDialogBuilder.create();
    Button startBtn = (Button) findViewById(R.id.btn);
    final TextView t = (TextView) findViewById(R.id.hello);
    startBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            URL url;
            HttpURLConnection urlConnection = null;
            try {
                url = new URL("http://www.chatty.co.il/biyum.php?q=mkyong");
                urlConnection = (HttpURLConnection) url.openConnection();
                InputStream in = urlConnection.getInputStream();
                InputStreamReader isw = new InputStreamReader(in);
                int data = isw.read();
                while (data != -1) {
                    char current = (char) data;
                    data = isw.read();
            } catch (Exception e) {
            } finally {
                if (urlConnection != null) {



$update_offline="INSERT INTO offline_waiters (user_partner,mail,chat_room) VALUES(0,'gavno','gavno')";
$query_run= mysqli_query($conn,$update_offline);

echo "new";


its a simple test that should enter a new row in my table. when I make the request manualy via a browser it works fine.

once again please help me understand where is the problem

I am working on a project with SOAP in Android Studio. I am new to SOAP and I have researched some articles. I am about to solve SOAP but I am stuck on something. I have a XML structure and I cannot get data from this XML tag. Actually I dont have any idea about the tags that start with "tem:...".


    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">

And my Class to consume data

public void CallWebService() {
        final Date date = new Date();
        final String getCurrentDate = new SimpleDateFormat("dd:MM:yyyy HH:mm", Locale.ROOT).format(date);

        Thread thread = new Thread(new Runnable() {
            public void run() {
                key = encryptManager.PushData("RequestIsValid" + getCurrentDate);
                Log.i("Key: ", key);

                key2 = sharesandIndexesListManager.PushData2("true","test","ipad",key,"Day");
                Log.i("Key2: ", key2);

thread.start(); }

I see "key" var in log cause I see type of the variable in the web url but I dont see types of the variables, -for instance tem:DeviceType- in the web url. In addition Key2 returns null. Please help me:) Thanks.

And the error: org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@21da6108)

I am using Volley in Fragments for the first time.

Can anyone help me with this. I am trying this following code for the fragment which I am calling from a navigation drawer:

public class ChangePassword extends android.app.Fragment implements View.OnClickListener
    EditText etOldSignUpPassword;
    EditText etNewSignUpPassword;
    EditText etNewSignUpConfirmPassword;
    ImageButton imageChangePasswordButton;
    ProgressBar pbWeb;
    String old,npass,ncpass;

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v =  inflater.inflate(R.layout.fragment_change_password, container, false);
    etOldSignUpPassword = (EditText)v.findViewById(R.id.etOldPassword);
    etNewSignUpPassword = (EditText)v.findViewById(R.id.etNewSignUpPassword);
    etNewSignUpConfirmPassword = (EditText)v.findViewById(R.id.etSignUpConfirmPassword);
    imageChangePasswordButton = (ImageButton)v.findViewById(R.id.imageChangePasswordButton);
    pbWeb = (ProgressBar)v.findViewById(R.id.pbWebC);


    return v;
public void onClick(View view) {
    if(view.getId() == R.id.imageChangePasswordButton) {

        old = etOldSignUpPassword.getText().toString();
        npass = etNewSignUpPassword.getText().toString();
        ncpass = etNewSignUpConfirmPassword.getText().toString();

        if (!isNetworkAvailable()) {
            Toast.makeText(getActivity(), "Your Wifi/Data is disabled. Please switch on and try again", Toast.LENGTH_SHORT).show();
        } else {
            String server_url = "url_working_fine_for_activity_so_no_issue_here";
            StringRequest strReq = new StringRequest(Request.Method.POST, server_url, new Response.Listener<String>() {
                public void onResponse(String response) {
                    if (response.equals("SUCCESS")) {
                        Toast.makeText(getActivity(), "Password Changed Successfully", Toast.LENGTH_SHORT).show();
                        Intent loginIntent = new Intent(getActivity(), LoginActivity.class);
                    } else {
                        Toast.makeText(getActivity(), "Couldn't Change Password. Old Password Exists", Toast.LENGTH_SHORT).show();

            }, new Response.ErrorListener() {
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(getActivity(), error.toString(), Toast.LENGTH_SHORT).show();
            }) {
                protected Map<String, String> getParams() throws AuthFailureError {
                    Map<String, String> map = new HashMap<String, String>();
                    map.put("old", old);//etOldPassword.getText().toString() throws NullPointerException
                    map.put("new", npass);//"MY_DEFAULT_VALUE" as value is working fine but that is not the use case
                    map.put("newCon", ncpass);
                    return map;
            //VolleySingleton is fine as working in Activity as well as when I give default values in getParams so no issue in this class 

Currently this code leads to a crash.

If in getParams, I am using etOldPassword.getText().toString(), I get NullPointerException.

I have tried using onClickListener() directly on imageChangePasswordButton inside onActivityCreated() method without implemeting onClickListener on the class but found on a thread that there is a bug.

Please let me know if I am missing something. Thanks

I'm a designer/developer in the National Collegiate Dodgeball Association, and we wanted to develop an Android app for officials to use on the court during matches. It's small, it won't be used by more than 10-15 people per week, only a few months out of the year.

One feature we're struggling with: We want to handle a game clock that is consistent and interactive across 3-4 devices, communicating over a basketball court (about 60'/20 m). How can I achieve this / what can I look into?

newbie to the forum here.

I've been trying to find an answer for what I had originally thought was a fairly straight-forward question...but for the life of me, I've been unable to do so.

I have an Android app that writes a message (string) to a passive NFC tag. When a user scans the tag, the message I wrote displays, using the native NFC tag reader. (if available).

I'd like to do the following, using Android Studio, if possible:

  1. Change the functionality of the "Write To Tag" app...so that it assigns the tag an "ID". I no longer want to have this message display to the user...rather I'd just assign it to a variable that will be used in the next step.

  2. Upon scanning, I'd like to create a flat file that is sent to a cloud based database with the following information: -The "ID" of the tag that is scanned. -The date/time of the scan -The device type/version that performed the scan, if available

  3. For the same scan event, I'd like to direct the user to a web site, unique to each tag. (hard-coded)

Basically, I'm attempting to execute consecutive "send" functions from a single scan. I've never done this before and I'm not even sure if it's possible?

I'm happy to provide any code examples from my "Write To" app if needed...and I thank you in advance for your help!

I'm building apps on iOS and Android using Firebase auth and I'm having a hard time getting it to work out. This is my function to check if a user's UID is on the whitelist in my database. After this function is called in viewDidLoad(_:) it will get past the guard statement then exit the function without entering the completion block.

func checkUserAgainstDatabase(completion: (success: Bool) -> Void) {
    guard let currentUser = FIRAuth.auth()?.currentUser else { return }
    FirebaseController.ref.child("users").observeSingleEventOfType(.Value, withBlock: { (data) in

// This is where the function exits and the program continues running.

        let uid = data.childSnapshotForPath(currentUser.uid)
        if uid.exists() {
            completion(success: true)
        } else {
            completion(success: false)

Here is the call in viewDidLoad(_:):

UserController.shared.checkUserAgainstDatabase { (success) -> Void in
    if !success {

Here are my rules on the database:

  "rules": {
    ".read": true,
    ".write": true

Thanks in advance!

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.axxessweb.agencycore/com.xxx.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
   at android.app.ActivityThread.access$900(ActivityThread.java:157)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5551)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
   at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:99)
   at com.axxessweb.agencycore.database.PatientDBAdapter.<init>(PatientDBAdapter.java:342)
   at com.axxessweb.agencycore.fragments.PatientFragment.onActivityCreated(PatientFragment.java:100)
   at android.app.Fragment.performActivityCreated(Fragment.java:2237)
   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:992)
   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1130)
   at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1953)
   at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:152)
   at android.app.Activity.performCreateCommon(Activity.java:6267)
   at android.app.Activity.performCreate(Activity.java:6274)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
   at android.app.ActivityThread.access$900(ActivityThread.java:157)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5551)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

I have problem with fit square image to height of screen.

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




The image @kwadrat is square size. How to change the width of border image? I tried set scaleType="fitXY" and adjustViewBounds="true" but it not give the good result

enter image description here

enter image description here

I am a freelance developer who was recently approached to help maintain and modify a profile through Apple Configuration(AC). The client has roughly 45 iPads that all use AC to promote their product while inside the store. Recently their developer left the position and now they are unable to update any of their products. While I understand that I may not be the most fit for this position (due to lack of experience), I would like to help them out in whichever way I can.

They were able to provide me with a .mobileconfig file and a .iosdevicebackup file. Before I tell them that I can help or not i'd like to confirm that these are the files I will be needing to move forward with their problem. From my understanding I simply need to use AC to create a USB profile to upload to the iPads. Is there anything here that I am missing?

It seems to me that Java is a highly general purpose language with a lot of good tooling / libraries built around it, and could be safely used to start any new project. So when is it not appropriate to choose Java for a new project?

As said in the title, which data type should a lexer return/give the parser? When reading the Lexical analysis article that Wikipedia has, it stated that:

In computer science, lexical analysis is the process of converting a sequence of characters (such as in a computer program or web page) into a sequence of tokens (strings with an identified "meaning").

However, in complete contradiction to the above statement, When another question I'd asked on a different site(Code Review if you are curious) was answered, The person answering stated that:

The lexer usually reads the string and converts this into a stream (or a vector) of lexemes. The lexemes only need to be a stream of numbers.

and he gave this visual:

nl_output => 256
output    => 257
<string>  => 258

Later on in the article He mentioned Flex, a already existing lexer, and said writing 'rules' with it would be simple. He proceded to give me this example:

Space              [ \r\n\t]
QuotedString       "[^"]*"
nl_output          {return 256;}
output             {return 257;}
{QuotedString}     {return 258;}
{Space}            {/* Ignore */}
.                  {error("Unmatched character");}

To further my insight and get more information, I read the Wikipedia article about Flex. the Flex article showed that you could define a set of syntax rules, with tokens, in the following way:

digit         [0-9]
letter        [a-zA-Z]

"+"                  { return PLUS;       }
"-"                  { return MINUS;      }
"*"                  { return TIMES;      }
"/"                  { return SLASH;      }
"("                  { return LPAREN;     }
")"                  { return RPAREN;     }
";"                  { return SEMICOLON;  }
","                  { return COMMA;      }
"."                  { return PERIOD;     }
":="                 { return BECOMES;    }
"="                  { return EQL;        }
"<>"                 { return NEQ;        }
"<"                  { return LSS;        }
">"                  { return GTR;        }
"<="                 { return LEQ;        }
">="                 { return GEQ;        }
"begin"              { return BEGINSYM;   }
"call"               { return CALLSYM;    }
"const"              { return CONSTSYM;   }
"do"                 { return DOSYM;      }
"end"                { return ENDSYM;     }
"if"                 { return IFSYM;      }
"odd"                { return ODDSYM;     }
"procedure"          { return PROCSYM;    }
"then"               { return THENSYM;    }
"var"                { return VARSYM;     }
"while"              { return WHILESYM;   }

It seems to me that the Flex lexer is returning strings of keywords\tokens. But It could be returning constants that are equal to certain numbers.

If the lexer was going to return numbers, how would it read string literals? returning a number is fine for single keywords, But how would you deal with a string? Wouldn't the lexer have to convert the string to binary numbers and then the parser would convert the numbers back to a string. It seems much more logical(and easier) for the lexer to return strings, and then let the parser convert any number string literals into actual numbers.

Or could the lexer possible return both? I've been trying to write a simple lexer in c++, which lets you have only one return type for your functions. Thus leading me to ask my question.

To condense my question into a paragraph: When writing a lexer, and assuming that it could only return one data type(strings or numbers), which would be the more logical choice?

In my NodeJS project I use of course some packages, those packages relies on other packages. Some of the developer maintaining those packages are very slow at updating the packages they use in their own project. Even when the issue is regarding security.

Is it possible to bump up a nap package within a package?

In scaled Scrum release management, what's the code management strategy if there are unfinished features in the code base?

For example, SAFe agile framework recommends all teams complete sprints the same day (they run on the same cadence).

Say all the teams are preparing for a release --- they all meet their sprint goals in the last sprint of the release, except for 1 team (a few stories are still not ready, must be done in the next release).

How does your team manage this situation in terms of your code branching or management strategy?

I'm trying to avoid casting of any type. I have the following simple Bus class that you can use to register your handlers:

public interface IDomainEvent {}

public class Bus
    private static readonly IList<IHandler<IDomainEvent>> Handlers = new List<IHandler<IDomainEvent>>();

    public static void Register(IHandler<IDomainEvent> handler)
        if (handler != null)

    public static void Raise<T>(T eventData) where T : IDomainEvent
        foreach (var handler in Handlers)

public interface IHandler<T> 
    T Handle(T eventData);

public class UpdatePersonHandler : IHandler<Person>
    public Person Handle(Person eventData)
        var test = eventData.Name;
        return eventData;

This gives an error because it's not of type IDomainEvent

Bus.Register(new UpdatePersonHandler());

How can I restructure the Bus so that it is generic enough to hold ANY type of IHandler?

Obviously making Bus<T> is not the right solution, since Bus should handle any type of IHander

I've tried this (still error):

public interface IHandler<T> where T : IDomainEvent
    T Handle(T eventData);

public class UpdatePersonHandler : IHandler<Person> 
    public Person Handle(Person eventData)
        var test = eventData.Name;
        return eventData;

public class Person : IDomainEvent
    public string Name { get; set; }

Argument 1: cannot convert from 'ConsoleApplication1.UpdatePersonHandler' to 'ConsoleApplication1.IHandler'

public class Bus<T>
    private static readonly IList<IHandler<T>> Handlers = new List<IHandler<T>>();

    public static void Register(IHandler<T> handler)
        if (handler != null)

    public static void Raise(T eventData)
        foreach (var handler in Handlers) {

After this edit, code compiles and I'm able to run the following:

    Bus<Person>.Register(new UpdatePersonHandler());
    Bus<Person>.Raise(new Person {Name = "John"});

However, what about concurrency?, what if I want to handle Bus<Animal> ? at the same time. old values in Bus.List<T> would be lost-correct?

I'm strongly considering a web search engine for my next pet project. All the basic principles are clear, but some details are not. Namely, I can't find a neat way to search by exact match, e. g. "The Who".

This requirement imposes limitations on how I can modify the source text:

  1. I can't use a list of stop words (high frequency, low relevance words like prepositions - they might be very relevant in some corner cases!).
  2. I can't use stemming (converting words to their basic lexical form). If I do use it, I can't tell "program" from "programmed" and so on.

Not being able to cast all words to their basic forms and to throw away common low value words means a much, MUCH larger index. And worse, for the common search queries that do benefit from stemming, how do I even implement it? The only solution I see is keeping two indices - one with actual words and one with stemmed words, but having to keep two copies of the Internet is not really a solution - one is already plenty to make me scratch my head.

I've been using various server side languages/frameworks for developing back-end web applications. Every server-side framework that I've been using has the capability for returning views/templates (whole or part of a HTML page) as well as returning JSON responses which will then be interpreted by some front end JS.

I have heard the argument that returning JSON responses as opposed to some HTML with PHP/Python/ code snippets doing tasks such as looping through collections and printing out data/HTML elements in the template creates a more complete divide between frontend and backend of the application.

What are the main advantages of using JSON responses from the backend (and interpreting those JSON responses via some frontend framework) and creating a more RESTful type of application? And what are the main advantages of just returning templates/HTML to the client?

I'm using Appcelerator Studio 4.7 with SDK 5.4.0GA.

I want to use swipe back gesture to return to previous view controller, but instead my touch just moves ScrollableView views even though I start my gesture at the left edge of the screen. Swipe back gesture works fine if it's not over ScrollableView.

Everything was fine when I have used Titanium Studio 3.4. It's not possible to use it at the moment, because it's not supported and you can't even log in.

This issue is because of Appcelerator Studio, not because of SDK version. I have tried to use Titanium Studio and Appcelerator Studio with the same SDK version and only Appcelerator Studio had this issue. That was the reason I stuck with Titanium Studio a year ago, but now it's not possible.

Here is the related topic without solution: https://archive.appcelerator.com/topic/581/swipe-right-from-the-edge-to-go-back-to-the-previous-window-doesn-t-work-anymore-in-ios-using-sdk-3-5-1-ga-and-4-0-0-ga/4

Very new to using Mapbox, and having troubles setting the pitch/bearing of the mapView. Is there something like:

mapView.setPitch = 45

Any help is greatly appreciated!

I'm trying to add an image inside a circular CAShapeLayer so i started by creating a circle like so :

let circleContainer = UIBezierPath(arcCenter: pCenter, radius: radius - 10, startAngle: 0, endAngle: CGFloat(M_PI * 2), clockwise: true)
let imageSubLayer = CAShapeLayer()
imageSubLayer.path = circleContainer.CGPath


then to add the image i did:

let imageLayer = CALayer()
imageLayer.contents = UIImage(named: "pic")?.CGImage

//I've also tried adding the image directly to the circular CAShapeLayer like so but without any success:
imageSubLayer.contents = UIImage(named: "pic")?.CGImage

the problem is: the circleContainer is always showing black color when i run the app (see image below). what am i doing wrong ? thanks in advance!

enter image description here