Fix some issues in Location And remove some not needed toast and add getActivityString

This commit is contained in:
MOATAZ IBRAHIM ELDESOUKI TAWFEEK MOHAMMED 2017-02-14 22:33:18 +02:00
parent a8f7892e23
commit e3c317990d
6 changed files with 35 additions and 22 deletions

View File

@ -53,19 +53,18 @@ public class MainActivity extends AppCompatActivity {
ArrayList<DetectedActivity> tempList = ActivityRecognitionAPI.getArrayList(updatedActivities);
for (int i = 0; i < tempList.size(); i++) {
txt.append(MONITORED_ACTIVITIES[tempList.get(i).getType()-1] +" - "
+ tempList.get(i).getConfidence() +" - "
+ tempList.get(i).getVersionCode()+"\n");
txt.append(ActivityRecognitionAPI.getActivityString(MainActivity.this,
tempList.get(i).getType()) +" - "
+ tempList.get(i).getConfidence()+ "%"+"\n");
}
Toast.makeText(MainActivity.this, ""+tempList, Toast.LENGTH_SHORT).show();
txt.append("\n");
}
});
InternetAPI.networkListener(new ConnectivityReceiverListener() {
@Override
public void onNetworkConnectionChanged(boolean isConnected, int connectionProvider) {
//txt.append();
//Toast.makeText(MainActivity.this, ""+isConnected, Toast.LENGTH_SHORT).show();
txt.append("isConnected"+isConnected+" - "+ connectionProvider +"\n\n");
}
});
@ -73,21 +72,28 @@ public class MainActivity extends AppCompatActivity {
BatteryAPI.batteryListener(new BatteryReceiverListener() {
@Override
public void onBatteryInformationChanged(int level, int scale, int temperature, int voltage, float batteryPct, int status, boolean isCharging, int chargePlug, boolean usbCharge, boolean acCharge) {
//Toast.makeText(MainActivity.this, ""+level, Toast.LENGTH_SHORT).show();
txt.append("level is " + level + "/" + scale +
", temp is " + temperature +
", voltage is " + voltage
+ " status :" + status +
" chargePlug :" + chargePlug +
" Battery Pct : " + batteryPct * 100 +"\n\n");
}
});
LocationAPI.setLocationReceiverListener(new LocationReceiverListener() {
@Override
public void getLastKnownLocation(Location location) {
Toast.makeText(MainActivity.this, "Broadlocationss getLastKnownLocation "+location.toString()+"", Toast.LENGTH_SHORT).show();
txt.append("getLastKnownLocation "+location+"\n\n");
// Toast.makeText(MainActivity.this, "Broadlocationss getLastKnownLocation "+location.toString()+"", Toast.LENGTH_SHORT).show();
// Log.d("Taag", "Broadlocationss getLastKnownLocation "+location.toString()+"");
}
@Override
public void onLocationChanged(Location location) {
Toast.makeText(MainActivity.this, "Broadlocationss onLocationChanged "+location.toString()+"", Toast.LENGTH_SHORT).show();
Log.d("Taag", "Broadlocationss onLocationChanged "+location.toString()+"");
txt.append("onLocationChanged "+location+"\n\n");
// Toast.makeText(MainActivity.this, "Broadlocationss onLocationChanged "+location.toString()+"", Toast.LENGTH_SHORT).show();
// Log.d("Taag", "Broadlocationss onLocationChanged "+location.toString()+"");
}
});

View File

@ -86,4 +86,8 @@ public class ActivityRecognitionAPI
return arrayAdapter;
}
public static String getActivityString(Context context, int detectedActivityType) {
return Constants.getActivityString(context, detectedActivityType);
}
}

View File

@ -27,9 +27,10 @@ public class ActivityRecognitionBroadcast extends BroadcastReceiver
ArrayList<DetectedActivity> updatedActivities =
intent.getParcelableArrayListExtra(Constants.ACTIVITY_EXTRA);
Log.d("mezoTag", "okay here we are hhhhh");
// Log.d("mezoTag", "okay here we are hhhhh");
// Toast.makeText(context, "okay here we are hhhhh", Toast.LENGTH_SHORT).show();
Toast.makeText(context, "okay here we are hhhhh", Toast.LENGTH_SHORT).show();
// mDetectedActivities = new ArrayList<DetectedActivity>();
//
// // Set the confidence level of each monitored activity to zero.

View File

@ -72,14 +72,14 @@ public class BatteryStateReceiver extends BroadcastReceiver
temperature, voltage, batteryPct, status, isCharging,
chargePlug, usbCharge, acCharge);
}
Toast.makeText(context,
"level is " + level + "/" + scale +
", temp is " + temperature +
", voltage is " + voltage
+ " status :" + status +
" chargePlug :" + chargePlug +
" Battery Pct : " + batteryPct * 100,
Toast.LENGTH_SHORT).show();
// Toast.makeText(context,
// "level is " + level + "/" + scale +
// ", temp is " + temperature +
// ", voltage is " + voltage
// + " status :" + status +
// " chargePlug :" + chargePlug +
// " Battery Pct : " + batteryPct * 100,
// Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -203,7 +203,7 @@ public class LocationService extends Service implements
sendLocationToBroadcast(location);
if(locationReceiverListener !=null) {
locationReceiverListener.getLastKnownLocation(location);
locationReceiverListener.onLocationChanged(location);
// locationReceiverListener.onLocationChanged(location);
}
} catch (Exception e) {
}

View File

@ -69,7 +69,9 @@ public class LocationBroadcast extends BroadcastReceiver
if ("LocalStorage".equals(location.getProvider())) {
locationReceiverListener.getLastKnownLocation(location);
}
locationReceiverListener.onLocationChanged(location);
if (!"LocalStorage".equals(location.getProvider())){
locationReceiverListener.onLocationChanged(location);
}
}
float kMeter = location.getSpeed() * 3.6f;