I'm developing a (php) Web App which will sell dynamically generated real time cell phone numbers for cellular companies. A company will ask for, say, a thousand numbers and this app will check for available numbers and provide them.

The number will be an 8 digit figure. The first numbers will mostly be fixed as specific codes for a particular company, rest of the digits will be dynamically generated.

My question is whether

a) I should store all the sold numbers in database, if yes then:
   i)  Separate number in separate row or
   ii) All the numbers in a single row

b) Should store range of numbers i.e 32500001-32510000

Keeping performance and ease of handling the algorithm in mind, kindly suggest me your solution.

Situation & requirements

  • send incremental updates of a very simple "game" state (like a game, but at the same time just 1 person is allowed to play, the others watch the playing one) via WebRTC data channels (ordered, reliable)
  • safe: no collisions, meaning no 2 peers having the lock at the same time
  • no deadlocks
  • resistent against common network problems (peer suddenly crashed, peer loses network connection temporarily, ...)
  • there will be just a few peers being online at the same time --> no high scalability requirements
  • it does not have to be fair, meaning the peer requesting at first is not necessarily the one gaining the lock
  • no synchronous clock
  • no rollbacks, no additional software


see http://serverfault.com/questions/625502/webrtc-and-socket-io-websockets-heartbeat, becaues I think these are rather network questions


  • Signalling server: to handle WebRTC connection initiation and maintain a list of all connected peers
  • is connected to the peers via WebSockets (socket.io) and informs them about other peers being connected / disconnected
  • should be used as little as possible
  • Locking server: the peer, who currently has the lock
    • other peers can ask him to give up his role and pass it to them
    • at the beginning and after unexpected crashes of the current lock server there may be times where no lock server is available
    • Streaming server: has to be at the same time the locking server, but additionally sends a data stream (containing incremental updates after an initial full update) to each other peer - will neglect any requests to give up his position as locking server as long as he is streaming


  • peer connects to the signalling server --> receives list of already connected peers --> connects to each of them (fully meshed topology)
    • if there is already a locking server he will inform the new peer
    • streaming server notifies other peers if he stops streaming (--> is willed to let others be the locking / streaming server)

A: first time someone needs to have a lock to start streaming

  • requesting peer sends request with more or less "random" value (his local timestamp) to everyone else (following to the list received by the signalling server)
    • a peer receiving such a request answers
      • NACK, if:
        • he knows another peer, who is the locking server (may happen if the requesting peer does not know there is already one)
        • he is the locking server and he wants to continue streaming (--> he is the streaming server)
        • he has requested a lock with <= timestamp
        • he ACKed another peer's request, who had a <= timestamp than the current request
      • ACK, else
    • if the requesting peer received ACK from everyone else, he notifies the others, that he is now the locking server
    • if he receives a NACK, the request for a lock is considered as failed --> someone else got it
    • if a peer arrives during request phase he will NOT be asked for a ACK / NACK (do you see any reason?)
    • if a peer leaves during request it is considered as ACK

B: for following requests

  • just the locking server is asked --> NACK / ACK under the above mentioned conditions --> less traffic
  • if the locking server crashes --> use method A for the next request ...


  • with floor(N / 2) + 1 ACKs it will not work, because the list of connected peers may arrive asynchronously at the peers --> collision, because both may receive (N / 2) + 1 ACK following to their version of the connected peer list
  • the case with 2 equal timestamps will end in nobody becoming the locking server, then they have to try it another time, but should neither cause collisions nor deadlocks


  • How can be detected, that a peer was temporarily disconnected, because this case must be treated as a reconnect, too, if the datachannel, but NOT the WebSocket were closed (e.g. due to different heartbeat interval or start time)?
    • -> send test packet via WebSockets to make the signalling server confirm the temporarily crash and handle it as complete crash?


I have a web service based on a number of entity classes. one of them is shows below

@Table(name = "users")
@NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
@NamedQuery(name = "Users.findByUserName", query = "SELECT u FROM Users u WHERE u.userName = :userName"),
@NamedQuery(name = "Users.findByUserPassword", query = "SELECT u FROM Users u WHERE u.userPassword = :userPassword")})

public class Users implements Serializable {

private static final long serialVersionUID = 1L;

@Basic(optional = false)
@Column(name = "user_name")
private String userName;

@Basic(optional = false)
@Column(name = "user_password")
private String userPassword;

@JoinColumn(name = "user_category_id", referencedColumnName = "category_id")
@ManyToOne(optional = false)
private UserCategory userCategoryId;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "userName")
private List<UserRecord> userRecordList;

public Users() {

public Users(String userName) {
    this.userName = userName;

public Users(String userName, String userPassword) {
    this.userName = userName;
    this.userPassword = userPassword;

public String getUserName() {
    return userName;

public void setUserName(String userName) {
    this.userName = userName;

public String getUserPassword() {
    return userPassword;

public void setUserPassword(String userPassword) {
    this.userPassword = userPassword;

public UserCategory getUserCategoryId() {
    return userCategoryId;

public void setUserCategoryId(UserCategory userCategoryId) {
    this.userCategoryId = userCategoryId;

public List<UserRecord> getUserRecordList() {
    return userRecordList;

public void setUserRecordList(List<UserRecord> userRecordList) {
    this.userRecordList = userRecordList;

public int hashCode() {
    int hash = 0;
    hash += (userName != null ? userName.hashCode() : 0);
    return hash;

public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Users)) {
        return false;
    Users other = (Users) object;
    if ((this.userName == null && other.userName != null) || (this.userName != null && !this.userName.equals(other.userName))) {
        return false;
    return true;

public String toString() {
    return userName;


I was able to successfully deploy the web service and then i added a new Restful web client using netbeans, which created the following class

public class Client {
private WebTarget webTarget;
private javax.ws.rs.client.Client client;
private static final String BASE_URI = "http://localhost:31691/ProductionEntitiesService/api";

public Client() {
    client = javax.ws.rs.client.ClientBuilder.newClient();
    webTarget = client.target(BASE_URI).path("entities.users");

public <T> T find_XML(Class<T> responseType, String id) throws ClientErrorException {
    WebTarget resource = webTarget;
    resource = resource.path(java.text.MessageFormat.format("{0}", new Object[]{id}));
    return resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);

public <T> T findAll_XML(Class<T> responseType) throws ClientErrorException {
    WebTarget resource = webTarget;
    return resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);

public void close() {


This line of code then returned an xml result of the query

result = c.findAll_XML(String.class);

which had this format

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

However, this line of code

List<Users> l = (List<Users>)c.findAll_XML(Users.class);

produces an exception, which seems to be caused by the "userss" tag that surrounds the xml result, I'm not sure how that came about.

Can anyone help me resolve this?

Exception in thread "AWT-EventQueue-0" javax.ws.rs.BadRequestException: HTTP 400 Bad Request
at org.glassfish.jersey.message.internal.AbstractRootElementJaxbProvider.readFrom(AbstractRootElementJaxbProvider.java:124)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:188)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:134)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:988)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:833)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:768)
at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:96)
at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:740)
at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:88)
at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:650)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:421)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:646)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:375)
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:275)
at service.Client.findAll_XML(Client.java:83)
at examples.Find.<init>(Find.java:44)
at examples.Find$1.run(Find.java:166)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
 Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"userss"). Expected elements are <{}userCategory>,<{}users>
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:681)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:247)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:242)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:109)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1086)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:510)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:492)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:163)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:378)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:604)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3122)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:243)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:214)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:140)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:123)
at org.glassfish.jersey.message.internal.XmlRootElementJaxbProvider.readFrom(XmlRootElementJaxbProvider.java:140)
at org.glassfish.jersey.message.internal.AbstractRootElementJaxbProvider.readFrom(AbstractRootElementJaxbProvider.java:122)
... 33 more

I am working on a Scala project and I want to include some sample data somewhere in the project. Specifically, my Scala project includes code that performs various natural language processing tasks on text data. I want to include a sample set of text files that the user can use to test out the program somewhere in the project structure. Right now I am putting this sample data in the resources folder (mostly because it is the only location within the project that I know how to read from). But I was wondering if this is the best location? In general what is the best practice regarding where to put sample data within the project? Alternatively, would it be a better idea to simply provide this data separately (i.e external to the project)?

I have set up my ASP.NET MVC project as follows:

Presentation Layer : ViewModels, Views, Certain logic to handle service responses

Business Logic / Service Layer : Services that work with data from either database or presentation layer. (Domain models is EF entities)

Database Access Layer : Entity Framework.

according to http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application#repo a repository/unit of work pattern is no longer needed with EF6.

And working with ASP.NET Identity creating a interface for DbContext is hard, making all services have a tight coupling to the ApplicationDbContext.

Is this okay? in the scenario you have to change database to NoSQL, you would have to change all the Services code instead of just the "middleware".

Any comments to architecture is welcome aswell. I am trying to find a good stand point for creating an application.

Occasionally while typing something up that relates to a case sensitive programming language I end up starting a sentence with a function name. Now the rules of English state that the first word in a sentence needs to be capitalized however the function name is lowercase. If you are wondering what could I be saying that would result in the first word being a function name take this example:

Your fread implementation is broken. fread needs to return how many bytes were read.

I understand that I could change the second instance of fread to It however I want to know the proper way of handling this other than just rewriting the sentence as in should I capitalize the function name? The only way I would like to hear rewrite the sentence as an answer is if starting the sentence with a function name violates some English rule that I am not aware of.

How can I tell if a study material is out of date. And by this I mean too dated to be make useful and worthwhile reading.

An example is a book I have just purchased named 'Building Internet Firewalls' published by O'Reilly.

Another example is TCP/IP network administration by the same publisher as the above.

Would these books still be relevant today for somebody wishing to administer networks and build networking/network software?


  • My team uses scrum
  • I have currently no task assigned
  • There are no more pending task in the backlog
  • Today is Labor Day for my client.

Not having many things to do today I wanted to start refactoring some code I keep on seeing in the project I am working on, but currently I am not assigned to any sprint task to do any large scale refactoring.

Is it OK in Scrum if I start randomly refactoring code that I have and have not written that always bother me but don't have time other days to fix it because of other days assignments?

What about other days that I have spare time between sprints.

I actually do and believe in continuous refactoring. I always do it on the pieces of code that I am working when assigned a story but what about some other code I see that is not currently related to what I am working on at that moment?

I can only imagine there must be a way for me to invoke some kind of GUI that will show all the matches a player has going on, whose turn it is, who they're playing etc. Is there such a GUI call for Google Play Game Services or do I really need to work this all out manually by loading matches and created my own GUI from the data? It's proving to be a lot of work and I feel like it just HAS to be wasted effort. Game Center has it...

This might sound very basic, but in onDetach why/what should I be cleaning up? If the fragment is being destroyed shouldn't references, such as the Context, be automatically cleaned up for me?

I don't have any device older than 4.1 to test on. I'm trying to test out pushing my notifications with the code below. It's mostly all taken from the Notification documentation. Would my code crash or does the NotificationCompat class handle all of this for me gracefully?

Under the "Handling Compatability" section it reads:

Handling compatibility

Not all notification features are available for a particular version, even though the methods to set them are in the support library class NotificationCompat.Builder. For example, action buttons, which depend on expanded notifications, only appear on Android 4.1 and higher, because expanded notifications themselves are only available on Android 4.1 and higher.

To ensure the best compatibility, create notifications with NotificationCompat and its subclasses, particularly NotificationCompat.Builder. In addition, follow this process when you implement a notification:


So does this mean that if I use the NotificationCompat class it will handle all of the compatibility for me?

My code that I'm worried about (because it uses BigTextStyle):

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext).setSmallIcon(R.drawable.ic_launcher).setContentTitle("Title")
                .setContentText(String.format("%s", message));
        // Creates an explicit intent for an Activity in your app
        Intent resultIntent = new Intent(mContext, ActivityMain.class);

        // The stack builder object will contain an artificial back stack for
        // the
        // started Activity.
        // This ensures that navigating backward from the Activity leads out of
        // your application to the Home screen.
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
        // Adds the back stack for the Intent (but not the Intent itself)
        // Adds the Intent that starts the Activity to the top of the stack
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        // Add max priority
        // Add bigTextStyle
        NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
        bigTextStyle.bigText(String.format("%s", message));
        // mId allows you to update the notification later on.
        mNotificationManager.notify(1, mBuilder.build());

I want to set background for the button. With Android 4.1.2 everything works fine, but if launch with Android 4.0 I've got an error

java.lang.NoSuchMethodError: android.widget.Button.setBackground 

with code

LayerDrawable composite = new LayerDrawable(layers);

So how can I set LayerDrawable background but with Android 4.0 or earlier?

I am making an update in the UI thread also need to get GPS coordinates and speed. I know I need to use an AsyncTask. I am confused on how I do that since the way GPS Location works I need a LocationListner class and that does not return any values for me to use to make the UI update.

This is what I have so far but

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.AsyncTask;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class DrawChart extends Activity {

LinearLayout linearChart;

protected void onCreate(Bundle savedInstanceState) {


    Intent intent = getIntent();


private class CreatingSpeedGraphTask extends AsyncTask <Void, Float, Void> {

    DrawChart graph = new DrawChart();

    protected void onPreExecute() {

    protected float doInBackround(Object... params) {
        LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        LocationListener locListener = new MyLocationListener();

        locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);


        protected class MyLocationListener implements LocationListener {

            DatabaseHelper helper = DatabaseHelper.getInstance(getApplicationContext());
            DrawChart graph = new DrawChart();

            public void onProviderDisabled(String provider) {

            public void onProviderEnabled(String provider) {
                Toast.makeText(getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show();

            public void onStatusChanged(String provider, int status, Bundle extras) {


            public void onLocationChanged(Location loc) {

                // The current location will get the Lat Long and speed I am going at
                LocationObj currentLocation = new LocationObj(loc);
                // The next Location will calculate my next loaction o where I will be in t seconds
                LocationObj nextLocation = new LocationObj(loc);
                // The nearest location will pull my nearest location form the DB to see how fast I was going.
                LocationObj nearestLocation = new LocationObj(loc);

                // current speed will grab current speed I am traveling at.
                float currentSpeed = currentLocation.getSpeed();
                // will get the speed I was going at my next location
                float futureSpeed = nearestLocation.getSpeed();

                nextLocation = currentLocation.calculateNextLocation(1);
                nearestLocation = this.helper.getNearestLocation(nextLocation);

                //The next speed action I need to take to my next location.
                float actionSpeed = futureSpeed - currentSpeed;

    protected void postExecute() {

    protected void onProgressUpdate(float... speedChange) {

        float actionSpeed = speedChage;

        if (actionSpeed == 0) {
        else if (actionSpeed > 0 && actionSpeed <= 4.4) {
        else if (actionSpeed > 4.4 && actionSpeed <= 8.9) {
        else if (actionSpeed > 8.9 && actionSpeed <= 13.4) {
        else if (actionSpeed > 13.4) {
        else if (actionSpeed < 0 && actionSpeed >= -4.4) {
        else if (actionSpeed < -4.4 && actionSpeed >= -8.9) {
        else if (actionSpeed < -8.9 && actionSpeed >= 13.4) {
        else if (actionSpeed < -13.4) {


I've been reading Artificial Intelligence: A Modern Approach, which describes many techniques in AI. My problem is that often I don't know when to use a given technique. This can be for 2 reasons:

  1. Other techniques seem to be as good as or better than the given technique in every way. For example, Bayesian inference with variable elimination seems better than Bayesian inference by enumeration, so when should Bayesian inference by enumeration be used?

  2. Some techniques seem better than other techniques in some ways but not others, but no explanation was given for when to use each one. For example, how does one choose between using random-restart hill climbing and simulated annealing?

To cut a long story short, in my spare time I've been learning about the origins of music theory, and I want to create a simple program (for windows) that is basically a series of 12 buttons, each of which, when pressed, plays a tone of a specific frequency, and ideally beneath each button would be a dropdown menu which could change the frequency of the button.

It's completely for personal use, and doesn't have to look flashy at all. I've got absoloutely no experience doing anything like this before, so my first question is whether this is feasible? The only "coding" I've done is learning LaTeX in the course of doing a maths degree.

If it is feasible, how would I get started? I don't know if this kind of thing is created using "program creating software", or whether I'm looking to learn a specific type of code and notepad, or anything else I probably haven't thought of.

Thanks for any help!

Hi after endless forums and tries i guess i will need more help.

I need to combine two features in my app: 1. Android drawer. 2. Google map.

The idea is that the "main" screen of my app is a map, and the drawer will help me to change to settings, personal files, etc...

So the question is what is the best way to combine them? I mean i don't want to reopen the map each time I return to map(I have a database for the map and i dont want to reload it every time). And i want the drawer to appear through all screens.

Any ideas?

My code so far: (except other fragments which are blank pages with their names) Main activity xml:

  <?xml version="1.0"?>
    <android.support.v4.widget.DrawerLayout android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/drawer_layout" xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- <?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.google.android.gms.maps.MapFragment"/> -->
    <FrameLayout android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/content_frame"/>
    <ListView android:layout_height="match_parent" android:layout_width="240dp" android:id="@+id/left_drawer" android:background="#fff" android:dividerHeight="0dp" android:divider="@android:color/transparent" android:choiceMode="singleChoice" android:layout_gravity="start"/>

Main activity class:

    //import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
//import com.google.android.gms.maps.model.CameraPosition;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.view.View;

public class MapActivity extends Activity{

    public static FragmentManager fragmentManager;
    Fragment map = null;
    String[] menu;
    DrawerLayout dLayout;
    ListView dList;
    ArrayAdapter<String> adapter;
    protected void onCreate(Bundle savedInstanceState) {
        fragmentManager = getFragmentManager();
        menu = new String[]{"Home","Android","Windows","Linux","Raspberry Pi","WordPress","Videos","Contact Us"};
        dLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        dList = (ListView) findViewById(R.id.left_drawer);
        adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,menu);
        dList.setOnItemClickListener(new OnItemClickListener(){
            public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
                Bundle args = new Bundle();
                args.putString("Menu", menu[position]);
                Fragment detail = new DetailFragment();

                    if(position == 0){
    //                      if(map == null){
                                map = new MyMapFragment();
    //                      }
                        detail = map;
                    FragmentManager fragmentManager = getFragmentManager();

Map fragment xml:

<?xml version="1.0"?>

<fragment android:layout_height="match_parent" android:layout_width="match_parent" class="com.google.android.gms.maps.MapFragment" android:id="@+id/map"/>


Map fragment class:

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

    public class MyMapFragment extends Fragment{

    static final LatLng HAMBURG = new LatLng(53.558, 9.927);
    static final LatLng KIEL = new LatLng(53.551, 9.993);
    private GoogleMap googleMap;

    public void onCreate(Bundle savedInstanceState) {

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rooView = inflater.inflate(R.layout.fragment_mymap, container, false);
        return rooView;

    private void setUpMapIfNeeded() {
        if(googleMap == null){
            googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    private void setUpMap(){
        Marker hamburg = googleMap.addMarker(new MarkerOptions().position(HAMBURG)
        Marker kiel = googleMap.addMarker(new MarkerOptions()
        .snippet("Kiel is cool")
        // Move the camera instantly to hamburg with a zoom of 15.
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));

        // Zoom in, animating the camera.
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

    public void onDestroy() {
        if(googleMap != null){
            googleMap = null;

I am have viewpager with viewpager tabstrip using adrnoid support v4 library. How can I change the width of viewPagerTabStrip Highlighter(Indicator) ?

I have been investigating on the viability of a "normal" programming language with dependent types. Think for example in Java and add dependent types to it. One difficulty which I have found is that the type of a variable may change when mutated, like in the following piece of pseudo-code:

let xs = [1, 2, 3]; // The type of xs is List<int, 3>
let ys = [4, 5];    // The type of ys is List<int, 2>
xs.concat(ys);      // We concatenate the lists, so the type of xs is now List<int, 5>

This becomes a problem when we mutate a variable inside an if statement:

let xs = [1, 2, 3]; // The type of xs is List<int, 3>
if random_bool {
    xs.push(4);     // The type of xs is List<int, 4>
// The type of xs is unknown, because random_bool is set at runtime

Is there any research on this topic? Is it possible to address this issue without renouncing to mutability?

all, We are developing a game for platforms iOS and Android on Unity3D and we have come across the following problem: We want players "like/become a fan" of the facebook account in our game, but we have not found this option in your API. For Unity, we use the Facebook SDK for Unity 6.0. Maybe you can help us find a solution to this problem?

I have created call recording application that record all incoming and outgoing call. Application works perfectly I have tested it. I need to send background email (without user invention using JAVAMAIL) for recorded file. I have working code for sending mail with attachment. I have created broadcast receiver that listen PHONE_STATE and NEW_OUTGOING_CALL. Broadcast Receiver start/stop Recording service as per Phone state change. My question is how should I integrate my email sending code with application. I know I have to called mail sending method in CALL_STATE_IDLE. But as the method call multiple time I am not able to do so.

I am confused that is CALL_STATE_IDLE is right place to send email in background because it occurs multiple time.



any help plz.. thanks in advance


public class CallBroadcastReceiver extends BroadcastReceiver {
    public static boolean IsOutgoingCall = false;
    public static String callNumber = "";

    public void onReceive(Context context, Intent intent) {

        Log.d("CallRecorder", "CallBroadcastReceiver::onReceive got Intent: "
                + intent.toString());
        if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {

            String numberToCall = intent
                    "CallBroadcastReceiver intent has EXTRA_PHONE_NUMBER: "
                            + numberToCall);
            IsOutgoingCall = true;
            callNumber = numberToCall;

        PhoneListener phoneListener = new PhoneListener(context, intent);
        TelephonyManager telephony = (TelephonyManager) context
        telephony.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
        Log.d("PhoneStateReceiver::onReceive", "set PhoneStateListener");



public class PhoneListener extends PhoneStateListener {
    public static Context context;
    private Intent intent;

    public PhoneListener(Context c, Intent i) {
        Log.i("CallRecorder", "PhoneListener constructor");
        context = c;
        intent = i;

    public void onCallStateChanged(int state, String incomingNumber) {
        Log.d("CallRecorder", "PhoneListener::onCallStateChanged state:"
                + state + " incomingNumber:" + incomingNumber);

        switch (state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Log.d("CallRecorder", "CALL_STATE_IDLE, stoping recording");
            Boolean stopped = context.stopService(new Intent(context,
            Log.i("CallRecorder", "stopService for RecordService returned "
                    + stopped);

        case TelephonyManager.CALL_STATE_RINGING:

            Log.d("CallRecorder", "CALL_STATE_RINGING");
                    "CallBroadcastReceiver intent has EXTRA_PHONE_NUMBER: "
                            + incomingNumber);
            CallBroadcastReceiver.IsOutgoingCall = false;

            CallBroadcastReceiver.callNumber = incomingNumber;

        case TelephonyManager.CALL_STATE_OFFHOOK:

            Log.d("CallRecorder", "CALL_STATE_OFFHOOK starting recording");
            Intent callIntent = new Intent(context, RecordService.class);
            ComponentName name = context.startService(callIntent);
            if (null == name) {
                        "startService for RecordService returned null ComponentName");
            } else {
                        "startService returned " + name.flattenToString());


File attachedFile = new File("/mnt/sdcard/Recording/123456789.mp4");
                if(attachedFile.exists() && attachedFile.canRead())
                    Log.v("SendMail", "File Exists");
                    GMailSender sender = new GMailSender("your@gmail.com","your@gmail.com"); //<<< Enter Here
                    sender.sendMail("Subject", "Body ", 
                            "your@gmail.com", "to@gmail.com", attachedFile);

                    emailsStatus = 1; // Send
                    emailsStatus = 2; // File Not Exists
                    Log.v("SendMail", "File Not Exists");

I'm calling the fragment from the main activity:


AdExample.java source code:

public class AdExample extends Fragment {

    private ListView listView;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        // getting access to layout
        View view = inflater.inflate(R.layout.ad_example, container, false);
        listView = (ListView) view.findViewById(R.id.listView);

        MovieAdapter adapter = new MovieAdapter(getActivity(), initData());


        return view;

    private List<MovieItem> initData () {
        List<MovieItem> list = new ArrayList<MovieItem>();

        list.add(new MovieItem("Item1", "Desc1", 2014));
        list.add(new MovieItem("Item2", "Desc2", 2014));
        list.add(new MovieItem("Item3", "Desc3", 2014));

        return list;

But as a result I get a blank ListView. Have I missed something in the above code?



Here is MovieAdapter.java source code:

public class MovieAdapter extends BaseAdapter {

    private List<MovieItem> list;
    private LayoutInflater layoutInflater;

    public MovieAdapter(Context context, List<MovieItem> list) {
        this.list = list;
        layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    public int getCount() {
        return 0;

    public Object getItem(int position) {
        return list.get(position);

    public long getItemId(int position) {
        return position;

    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        if (view == null) {
            view = layoutInflater.inflate(R.layout.movie_item, parent, false);

        TextView name = (TextView) view.findViewById(R.id.nameText);

        return view;

    private MovieItem getMovieItem(int position ) {
        return (MovieItem) getItem(position);