Example #1
1
  public static String submitPostData(String pos, String data) throws IOException {
    Log.v("req", data);

    URL url = new URL(urlPre + pos);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    configConnection(connection);
    if (sCookie != null && sCookie.length() > 0) {
      connection.setRequestProperty("Cookie", sCookie);
    }
    connection.connect();

    // Send data
    DataOutputStream output = new DataOutputStream(connection.getOutputStream());
    output.write(data.getBytes());
    output.flush();
    output.close();

    // check Cookie
    String cookie = connection.getHeaderField("set-cookie");
    if (cookie != null && !cookie.equals(sCookie)) {
      sCookie = cookie;
    }

    // Respond
    BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    StringBuilder sb = new StringBuilder();
    String line = null;
    while ((line = reader.readLine()) != null) {
      sb.append(line + "\n");
    }
    connection.disconnect();
    String res = sb.toString();
    Log.v("res", res);
    return res;
  }
 public void release() {
   if (startTime != null) {
     Long endTime = System.currentTimeMillis();
     if (K9.DEBUG) {
       Log.v(
           K9.LOG_TAG,
           "TracingWakeLock for tag "
               + tag
               + " / id "
               + id
               + ": releasing after "
               + (endTime - startTime)
               + " ms, timeout = "
               + timeout
               + " ms");
     }
   } else {
     if (K9.DEBUG) {
       Log.v(
           K9.LOG_TAG,
           "TracingWakeLock for tag "
               + tag
               + " / id "
               + id
               + ", timeout = "
               + timeout
               + " ms: releasing");
     }
   }
   cancelNotification();
   synchronized (wakeLock) {
     wakeLock.release();
   }
   startTime = null;
 }
Example #3
0
 @Override
 public void onCreate() {
   Log.v("MyAlarmServiceログ", "Create");
   Thread thr = new Thread(null, mTask, "MyAlarmServiceThread");
   thr.start();
   Log.v("MyAlarmServiceログ", "スレッド開始");
 }
  /**
   * Handle the specified CALL or CALL_* intent on a non-voice-capable device.
   *
   * <p>This method may launch a different intent (if there's some useful alternative action to
   * take), or otherwise display an error dialog, and in either case will finish() the current
   * activity when done.
   */
  private void handleNonVoiceCapable(Intent intent) {
    if (DBG)
      Log.v(TAG, "handleNonVoiceCapable: handling " + intent + " on non-voice-capable device...");
    String action = intent.getAction();
    Uri uri = intent.getData();
    String scheme = uri.getScheme();

    // Handle one special case: If this is a regular CALL to a tel: URI,
    // bring up a UI letting you do something useful with the phone number
    // (like "Add to contacts" if it isn't a contact yet.)
    //
    // This UI is provided by the contacts app in response to a DIAL
    // intent, so we bring it up here by demoting this CALL to a DIAL and
    // relaunching.
    //
    // TODO: it's strange and unintuitive to manually launch a DIAL intent
    // to do this; it would be cleaner to have some shared UI component
    // that we could bring up directly.  (But for now at least, since both
    // Contacts and Phone are built-in apps, this implementation is fine.)

    if (Intent.ACTION_CALL.equals(action) && (Constants.SCHEME_TEL.equals(scheme))) {
      Intent newIntent = new Intent(Intent.ACTION_DIAL, uri);
      if (DBG) Log.v(TAG, "- relaunching as a DIAL intent: " + newIntent);
      startActivity(newIntent);
      finish();
      return;
    }

    // In all other cases, just show a generic "voice calling not
    // supported" dialog.
    showDialog(DIALOG_NOT_VOICE_CAPABLE);
    // ...and we'll eventually finish() when the user dismisses
    // or cancels the dialog.
  }
  @Override
  protected void onProgressUpdate(String... values) {
    super.onProgressUpdate(values);

    // EditText passwordField = (EditText)
    // parent.findViewById(R.id.LoginScreen_EditTextPassword);

    String[] message_parts = values[0].split(":");

    // FORMAT: [TYPE]:[EMAIL]:[TOKEN]:[DATA]:[EOP]
    // 0 1 2 3 4
    Log.v("REC_M", "RECEIVED:" + values[0]);

    if (message_parts.length == 5) {
      String TYPE = message_parts[0];
      String Status = message_parts[3];

      Log.v("TYPE", "TYPE:" + TYPE);

      if (TYPE.equals("STATUS")) {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(parent);
        alertDialog.setTitle("             User Alert !");
        alertDialog.setMessage(Status);
        alertDialog.setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {}
            });

        alertDialog.show();
        (parent.findViewById(R.id.ForgotPassword_ButtonResetPassword)).setEnabled(true);
      }
    }
  }
    @Override
    public void onReceiveLocation(BDLocation location) {
      if (location == null) return;

      locData.latitude = location.getLatitude();
      Log.v("qianjin", "qianjin" + locData.latitude);
      locData.longitude = location.getLongitude();
      Log.v("qianjin", "qianjin" + locData.longitude);
      // 如果不显示定位精度圈,将accuracy赋值为0即可
      locData.accuracy = location.getRadius();
      // 此处可以设置 locData的方向信息, 如果定位 SDK 未返回方向信息,用户可以自己实现罗盘功能添加方向信息。
      locData.direction = location.getDerect();
      // 更新定位数据
      myLocationOverlay.setData(locData);
      // 更新图层数据执行刷新后生效
      mMapView.refresh();
      // 是手动触发请求或首次定位时,移动到定位点
      if (isRequest || isFirstLoc) {
        // 移动地图到定位点
        Log.d("LocationOverlay", "receive location, animate to it");
        mMapController.animateTo(
            new GeoPoint((int) (locData.latitude * 1e6), (int) (locData.longitude * 1e6)));
        isRequest = false;
        myLocationOverlay.setLocationMode(LocationMode.FOLLOWING);
        requestLocButton.setText("跟随");
        mCurBtnType = E_BUTTON_TYPE.FOLLOW;
      }
      // 首次定位完成
      isFirstLoc = false;
    }
  /**
   * If received foundAdvName: <br>
   * Stop the scheduled timer. <br>
   * If reachable state is false - set it to true and call the registry with reachability state
   * changed
   *
   * @param args Event handler argument
   */
  private void handleFoundAdvName(Map<String, Object> args) {
    String foundSender = (String) args.get("SENDER");

    Log.v(
        TAG,
        "Received foundAdvertisedName of sender: '"
            + foundSender
            + "', my sender name is: '"
            + sender
            + "'");
    if (foundSender == null || !foundSender.equals(sender)) {
      Log.v(TAG, "The received sender: '" + foundSender + "' doesn't belong to this device");
      return;
    }

    stopDeviceFoundVerificationService();

    // Atomically sets the value to the given updated value if the current value == the expected
    // value.
    // Returns - true if successful. False return indicates that the actual value was not equal to
    // the expected value
    if (isReachable.compareAndSet(false, true)) {
      boolean newVal = isReachable.get();
      Log.d(TAG, "The device: '" + deviceId + "' isReachable set to: '" + newVal + "'");
      deviceRegistry.reachabilityChanged(this, newVal);
    }
  } // handleFoundAdvName
Example #8
0
    private String readHeader(InputStream is) throws IOException {
      int len, offset = 0;
      int size = 512;
      byte buf[] = new byte[size];

      while (offset < size) {
        int i;

        len = is.read(buf, offset, size - offset);
        if (len < 0) {
          break;
        }
        Log.v(TAG, "bytes read: " + len);
        String s = new String(buf);
        String lines[] = s.split("\r\n");
        Log.v(TAG, "lines read: " + lines.length);

        for (i = 0; i < lines.length; i++) {
          if (lines[i].length() == 0) {
            return s;
          }
        }

        offset += len;
      }

      return null;
    }
  private boolean checkUplink() {

    Log.v(TAG, "Dentro CheckupLink()");

    if (!app.prefs.getBoolean("wan_start", false)) { // se la wan è disabilitata niente check
      Log.v(TAG, "Dentro CheckupLink(), WanStart False");
      return true;
    }
    if (app.prefs.getBoolean("wan_nowait", false)) {
      Log.v(TAG, "Dentro CheckupLink(), Wan_NoWait True");
      return true;
    }

    // NetworkInfo mobileInfo =connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    NetworkInfo wimaxInfo = connManager.getNetworkInfo(6);
    Log.v(TAG, "Dentro CheckupLink(), prima del return");
    // Cerco se esiste una interfaccia UMTS
    NetworkInfo[] info = connManager.getAllNetworkInfo();
    boolean umts = false;
    if (info != null) {
      for (int i = 0; i < info.length; i++) {
        if (info[i].getType() == connManager.TYPE_MOBILE) {
          // log(true, "Hspa interface "+info[i].getSubtypeName()+" found");
          if (info[i].getState() == NetworkInfo.State.CONNECTED) umts = true;
        }
      }
    }
    return (umts || ((wimaxInfo != null) && wimaxInfo.isConnected()));
  }
Example #10
0
  /* package */ HttpParameter[] asHttpParameterArray(final HttpParameter includeEntities) {
    final ArrayList<HttpParameter> params = new ArrayList<HttpParameter>();
    appendParameter("status", status, params);
    if (-1 != inReplyToStatusId) {
      appendParameter("in_reply_to_status_id", inReplyToStatusId, params);
    }
    if (location != null) {
      appendParameter("lat", location.getLatitude(), params);
      appendParameter("long", location.getLongitude(), params);
    }
    appendParameter("place_id", placeId, params);
    if (!displayCoordinates) {
      appendParameter("display_coordinates", "false", params);
    }
    params.add(includeEntities);
    if (null != mediaFile) {
      Log.v("StatusUpdate", "null != mediaFile");
      params.add(new HttpParameter("media[]", mediaFile));
      params.add(new HttpParameter("possibly_sensitive", possiblySensitive));
    } else if (mediaName != null && mediaBody != null) {
      Log.v("StatusUpdate", "mediaName != null && mediaBody != null");
      params.add(new HttpParameter("media[]", mediaName, mediaBody));
      params.add(new HttpParameter("possibly_sensitive", possiblySensitive));
    }

    final HttpParameter[] paramArray = new HttpParameter[params.size()];
    for (HttpParameter param : params) {
      Log.v("StatusUpdate", "name " + param.getName());
      Log.v("StatusUpdate", "name " + param.getValue());
    }

    return params.toArray(paramArray);
  }
Example #11
0
    @Override
    public void run() {
      super.run();

      try {
        start = 0;
        end = 0;
        url = null;

        InputStream is = socket.getInputStream();
        OutputStream os = socket.getOutputStream();
        String hdr = readHeader(is);
        parseHeader(hdr);
        if (url != null) {
          if (end > start) {
            respond_partial(os);
          } else {
            respond_full(os);
          }
        } else {
          Log.v(TAG, "skip response");
        }
        is.close();
        os.close();
        socket.close();
      } catch (IOException ioe) {
        Log.v(TAG, "io exception");
      }
    }
Example #12
0
 @Override
 public void waitForConnect() throws ConnectionLostException {
   synchronized (this) {
     if (disconnect_) {
       throw new ConnectionLostException();
     }
     try {
       socket_ = createSocket(device_);
     } catch (IOException e) {
       throw new ConnectionLostException(e);
     }
   }
   // keep trying to connect as long as we're not aborting
   while (true) {
     try {
       Log.v(TAG, "Attempting to connect to Bluetooth device: " + name_);
       socket_.connect();
       Log.v(TAG, "Established connection to device " + name_ + " address: " + address_);
       break; // if we got here, we're connected
     } catch (Exception e) {
       if (disconnect_) {
         throw new ConnectionLostException(e);
       }
       try {
         Thread.sleep(1000);
       } catch (InterruptedException e1) {
       }
     }
   }
 }
Example #13
0
  public short attack(Monster s) {
    Player p = this.getPlayer();

    int playersPhysicalAttack = p.getPhysicalDamage();
    int playersMagicalAttack = p.getMagicalDamage();
    if (p.isCritHit()) {
      playersPhysicalAttack += (playersPhysicalAttack * p.getCritDamageBonus()) / 100;
      playersMagicalAttack += (playersMagicalAttack * p.getCritDamageBonus()) / 100;
    }

    Log.v("Attack", "player_physical_dmg:" + playersPhysicalAttack);
    Log.v("Attack", "player_magical_dmg:" + playersMagicalAttack);

    s.incomingDamage(playersPhysicalAttack, playersMagicalAttack);
    if (!s.isDead()) {
      int monstersPhysicalAttack = s.getPhysicalDamage();
      int monstersMagicalAttack = s.getMagicalDamage();

      Log.v("Attack", "monst_physical_dmg:" + monstersPhysicalAttack);
      Log.v("Attack", "monst_magical_dmg:" + monstersMagicalAttack);

      p.incomingDamage(monstersPhysicalAttack, monstersMagicalAttack);

      if (p.isDead()) return -1;
      else return 0;

    } else {

      // delete monster from list
      return 1;
    }
  }
Example #14
0
  @Override
  public CachedImage get(CachedImageKey key) {
    boolean isContain = containsKey(key);
    if (!isContain) {
      return null;
    }

    CachedImage cachedImage = memoryCache.get(key);
    if (cachedImage != null && cachedImage.getWrap() != null) {
      if (Logger.isDebug()) Log.v("ImageCache", "hit memory cache");
      return cachedImage;
    }

    CachedImage temp = read(key);
    Bitmap bitmap = null;
    if (temp != null) {
      bitmap = temp.getWrap();
      if (cachedImage != null) {
        cachedImage.setWrap(bitmap);
      } else {
        cachedImage = temp;
        memoryCache.put(key, cachedImage);
      }
      if (Logger.isDebug()) Log.v("ImageCache", "hit local cache");
    }

    return cachedImage;
  }
  @Nullable
  private XmppAxolotlMessage buildHeader(Contact contact) {
    final XmppAxolotlMessage axolotlMessage =
        new XmppAxolotlMessage(contact.getJid().toBareJid(), getOwnDeviceId());

    Set<XmppAxolotlSession> contactSessions = findSessionsforContact(contact);
    Set<XmppAxolotlSession> ownSessions = findOwnSessions();
    if (contactSessions.isEmpty()) {
      return null;
    }
    Log.d(
        Config.LOGTAG,
        AxolotlService.getLogprefix(account) + "Building axolotl foreign keyElements...");
    for (XmppAxolotlSession session : contactSessions) {
      Log.v(
          Config.LOGTAG,
          AxolotlService.getLogprefix(account) + session.getRemoteAddress().toString());
      axolotlMessage.addDevice(session);
    }
    Log.d(
        Config.LOGTAG,
        AxolotlService.getLogprefix(account) + "Building axolotl own keyElements...");
    for (XmppAxolotlSession session : ownSessions) {
      Log.v(
          Config.LOGTAG,
          AxolotlService.getLogprefix(account) + session.getRemoteAddress().toString());
      axolotlMessage.addDevice(session);
    }

    return axolotlMessage;
  }
  public void buildNotification() {
    int notificationId = 2;

    //                    Intent viewIntent = new Intent(this, MainActivity.class);
    //                    PendingIntent viewPendingIntent =
    //                            PendingIntent.getActivity(this, 1000, viewIntent, 0);
    //
    //        Intent camIntent = new Intent(this, MySenderService.class);
    //        PendingIntent camPendingIntent = PendingIntent.getService(this, 0, camIntent, 0);

    Log.v(TAG, "Twitter Notification Start");

    NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(MyWearReceiverService.this)
            .setSmallIcon(R.drawable.hero)
            .setContentTitle("Twitter")
            .setContentText("Tweet Sent");
    // .setContentIntent(camPendingIntent)
    // .addAction(R.drawable.ic_camera_enhance_black_48dp, "Open Camera", camPendingIntent);

    // Get an instance of the NotificationManager service
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
    // Build the notification and issues it with notification manager.
    notificationManager.notify(notificationId, notificationBuilder.build());
    Log.v(TAG, "Twitter Notification Build Completed");
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   // create layout
   super.onCreate(savedInstanceState);
   setContentView(R.layout.calander_view);
   Log.v(TAG, "layout created");
   // get todays date
   GregorianCalendar userCalendar = (GregorianCalendar) GregorianCalendar.getInstance();
   // find stuff for main layout
   GridView calendar = (GridView) findViewById(R.id.calanderGridView);
   TextView month = (TextView) findViewById(R.id.calanderMonthView);
   Button back = (Button) findViewById(R.id.backMonth);
   Button forward = (Button) findViewById(R.id.forwardMonth);
   Button schedule = (Button) findViewById(R.id.addButtonView);
   Log.v(TAG, "found all elements in layout");
   // set the month to this month
   month.setText(
       theMonth(userCalendar.get(Calendar.MONTH)) + " " + userCalendar.get(Calendar.YEAR));
   Log.v(TAG, "successfully set month");
   // create grid adapter and set it
   MonthAdapter adapter = new MonthAdapter(this, userCalendar);
   calendar.setAdapter(adapter);
   Log.v(TAG, "created and added adapter");
   // add listeners
   back.setOnClickListener(new BackMonthListener(userCalendar, adapter, month));
   forward.setOnClickListener(new ForwardMonthListener(userCalendar, adapter, month));
   schedule.setOnClickListener(new ScheduleEventListener(this, adapter));
   Log.v(TAG, "set listeners");
 }
  @Override
  protected ArrayList<Review> doInBackground(String... params) {
    ArrayList<Review> reviews = new ArrayList<>();
    try {
      URL url = new URL(Constant.getReviewsUrl(movie.getId()));
      OkHttpClient client = new OkHttpClient();
      Request request = new Request.Builder().url(url).build();
      Response response = client.newCall(request).execute();
      String responseJSONString = response.body().string();
      if (response.isSuccessful()) {
        JSONObject responseJSON = new JSONObject(responseJSONString);
        JSONArray resultJSONArray = responseJSON.getJSONArray("results");
        for (int i = 0; i < resultJSONArray.length(); i++) {
          JSONObject reviewJSON = resultJSONArray.getJSONObject(i);
          String author = reviewJSON.getString("author");
          String content = reviewJSON.getString("content");
          Review review = new Review(movie.getId(), author, content);
          reviews.add(review);
        }
        return reviews;
      } else {
        Log.v("response", "code not 200");
        return null;
      }

    } catch (Exception e) {
      Log.v("response", e.toString());
      return null;
    }
  }
  /**
   * @param objPath
   * @param ifaceMask
   * @throws ControlPanelException
   */
  Unit addControlPanel(String objPath, int ifaceMask) throws ControlPanelException {
    Log.d(
        TAG,
        "Creating ControlPanelCollection object for objPath: '"
            + objPath
            + "', device: '"
            + deviceId
            + "'");

    // parse the received object path
    String[] segments = CommunicationUtil.parseObjPath(objPath);
    String unitId = segments[0];
    String panelId = segments[1];

    Unit unit = unitMap.get(unitId);

    if (unit == null) {
      Log.v(TAG, "Found new functional unit: '" + unitId + "', panel: '" + panelId + "'");
      unit = new Unit(this, unitId);
      unitMap.put(unitId, unit); // Store the new unit object
    } else {
      Log.v(TAG, "Found an existent functional unit: '" + unitId + "', panel: '" + panelId + "'");
    }

    if (CommunicationUtil.maskIncludes(ifaceMask, HTTPControl.ID_MASK)) {
      Log.d(TAG, "The objPath: '" + objPath + "' belongs to the HTTPControl interface, setting");
      unit.setHttpControlObjPath(objPath);
    } else {
      unit.createControlPanelCollection(objPath, panelId);
    }

    return unit;
  } // createUnit
Example #20
0
    private void writeToInternalStorage(GeotriggerConfig config) {

      Log.v(Config.TAG, "writeToInternalStorage");
      try {
        // String endOfLine = System.getProperty("line.separator");
        File file = new File(mContext.getFilesDir(), CONFIG_FILE);

        if (file.exists()) {
          file.delete();
        }

        file.createNewFile();

        // MODE_PRIVATE will create the file (or replace a file of the same name) and make it
        // private to your application. Other modes available are: MODE_APPEND, MODE_WORLD_READABLE,
        // and MODE_WORLD_WRITEABLE.
        FileOutputStream fos = new FileOutputStream(file, false);

        fos.write(config.toString().getBytes());

        Log.v(Config.TAG, "writeFileToInternalStorage complete.. " + config.toString());
        // writer.write(userName);

        fos.close();
      } catch (Exception e) {
        Log.v(Config.TAG, "Error: " + e.getMessage());
      }
    }
Example #21
0
  public void run() {
    while (ready == true) {

      int s;
      try {
        s = socket.getInputStream().read();

        while (s != -1) {
          if (s == 13) {
            Log.v("BluetoothThread", "received message: " + buffer);
            synchronized (parent) {
              parent.received(buffer);
            }
            buffer = "";
            s = (char) socket.getInputStream().read();
          } else {
            buffer += (char) s;
            Log.v("BluetoothThread", "received : " + s);
            s = (char) socket.getInputStream().read();
          }
        }
      } catch (IOException e) {
        Log.v("BluetoothThread", "IO Exception on receive");
        // alert the parent class
        // wait for reconnect
        ready = false;
        parent.received("DISCONNECT");
      }

      if (timeSinceLastDiscovery + 12000 < System.currentTimeMillis()) {
        timeSinceLastDiscovery = System.currentTimeMillis();
      }
    }
  }
Example #22
0
    private GeotriggerConfig readFromInternalStorage() {

      Log.v(Config.TAG, "read from internal storage");
      GeotriggerConfig config = null;
      try {
        File file = mContext.getFileStreamPath(CONFIG_FILE);
        if (file.exists() == true) {
          Log.v(Config.TAG, "readFileFromInternalStorage File found...");

          FileInputStream fis = mContext.openFileInput(file.getName());
          StringBuilder buffer = new StringBuilder();
          int ch;
          while ((ch = fis.read()) != -1) {
            buffer.append((char) ch);
          }

          Log.v(Config.TAG, "readFileFromInternalStorage complete.. " + buffer.toString());
          fis.close();

          config = new GeotriggerConfig(buffer.toString());
        }
      } catch (Exception e) {
        Log.v(Config.TAG, "Error: " + e.getMessage());
      }
      return config;
    }
Example #23
0
  private TaskData doInBackgroundSuspendCard(TaskData... params) {
    long start, stop;
    Deck deck = params[0].getDeck();
    Card oldCard = params[0].getCard();
    Card newCard;

    AnkiDb.database.beginTransaction();
    try {
      if (oldCard != null) {
        start = System.currentTimeMillis();
        deck.suspendCard(oldCard.id);
        stop = System.currentTimeMillis();
        Log.v(TAG, "doInBackgroundSuspendCard - Suspended card in " + (stop - start) + " ms.");
      }

      start = System.currentTimeMillis();
      newCard = deck.getCard();
      stop = System.currentTimeMillis();
      Log.v(TAG, "doInBackgroundSuspendCard - Loaded new card in " + (stop - start) + " ms.");
      publishProgress(new TaskData(newCard));
      AnkiDb.database.setTransactionSuccessful();
    } finally {
      AnkiDb.database.endTransaction();
    }

    return null;
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
      case R.id.remove_current_photo:
        removeProfilePicture();
        break;
      case R.id.take_photo:
        takePhoto();
        break;
      case R.id.choose_from_library:
        choosePhotoFromGallery();
        break;
      case R.id.import_from_facebook:
        Log.v("prototypev1", "face");
        break;
      case R.id.import_from_twitter:
        Log.v("prototypev1", "twitter");
        break;

      default:
        break;
    }
    return true;
  }
Example #25
0
 public static boolean MoveFile(FileInfo fileInfo, String dest) {
   if (fileInfo == null || dest == null) {
     Log.v(TAG, "MoveFile: null parameter");
     return false;
   }
   File file = fileInfo.getFile();
   String newPath = makePath(dest, file.getName());
   try {
     boolean isSuccess = file.renameTo(new File(newPath));
     Log.v(
         TAG,
         "file = "
             + file.getAbsolutePath()
             + " newFile = "
             + newPath
             + " isSuccess = "
             + isSuccess);
     return isSuccess;
   } catch (Exception e) {
     Log.v(
         TAG,
         "MoveFile: failed to move " + file.getAbsolutePath() + " exception = " + e.getMessage());
   }
   return false;
 }
  // Result from choose image from gallery and take photo
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
      case REQUEST_IMAGE_CAPTURE:
        if (resultCode == Activity.RESULT_OK && data != null) {
          Log.v("prototypev1", "he entrat a capturar fto");
          Bundle extras = data.getExtras();
          Bitmap photo = (Bitmap) extras.get("data");
          newProfilePicture = Bitmap.createScaledBitmap(photo, 80, 80, true);
          new SetProfilePictureTask().execute();
        }
        break;
      case REQUEST_PICK_IMAGE:
        Log.v("prototypev1", "he entrat a triar foto");
        if (resultCode == Activity.RESULT_OK && data != null) {
          Bitmap yourSelectedImage = searchPhotoSelect(data);
          newProfilePicture = Bitmap.createScaledBitmap(yourSelectedImage, 80, 80, true);
          // upload to parse
          new SetProfilePictureTask().execute();
        }
        break;

      default:
        break;
    }
    profilePicture.setImageBitmap(newProfilePicture);
  }
  /** {@inheritDoc} */
  @Override
  public void execute()
      throws InsufficientPermissionsException, NoSuchFileOrDirectory, ExecutionException {
    if (isTrace()) {
      Log.v(TAG, String.format("Creating from %s to %s", this.mSrc, this.mDst)); // $NON-NLS-1$
    }

    File s = new File(this.mSrc);
    File d = new File(this.mDst);
    if (!s.exists()) {
      if (isTrace()) {
        Log.v(TAG, "Result: FAIL. NoSuchFileOrDirectory"); // $NON-NLS-1$
      }
      throw new NoSuchFileOrDirectory(this.mSrc);
    }

    // Copy recursively
    if (!s.renameTo(d)) {
      if (isTrace()) {
        Log.v(TAG, "Result: FAIL. InsufficientPermissionsException"); // $NON-NLS-1$
      }
      throw new InsufficientPermissionsException();
    }

    if (isTrace()) {
      Log.v(TAG, "Result: OK"); // $NON-NLS-1$
    }
  }
  @Override
  public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null) {
      mCurTransaction = mFragmentManager.beginTransaction();
    }

    final long itemId = getItemId(position);

    // Do we already have this fragment?
    String name = makeFragmentName(container.getId(), itemId);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null) {
      if (DEBUG) Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
      mCurTransaction.attach(fragment);
    } else {
      fragment = getItem(position);
      if (DEBUG) Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
      mCurTransaction.add(container.getId(), fragment, makeFragmentName(container.getId(), itemId));
    }
    if (fragment != mCurrentPrimaryItem) {
      // FragmentCompat.setMenuVisibility(fragment, false);
      // FragmentCompat.setUserVisibleHint(fragment, false);
      setMenuVisibility(fragment, false);
      setUserVisibleHint(fragment, false);
    }

    return fragment;
  }
  /**
   * fills the list with stops from the local database
   *
   * @param db the database adapter to use
   */
  private void fillList(BusDbAdapter db) {
    Cursor c;
    if (listType == FAVORITES) {
      c = db.getFavoriteDest(NUM_ENTRIES_TO_FETCH);
    } else { // listType == MAJOR
      c = db.getMajorDest(NUM_ENTRIES_TO_FETCH);
    }
    int stopIDIndex = c.getColumnIndex("stop_id");
    int stopDescIndex = c.getColumnIndex("stop_desc");
    int routeIDIndex = c.getColumnIndex("route_id");
    int routeDescIndex = c.getColumnIndex("route_desc");
    if (c != null) {
      for (int i = 0; i < c.getCount(); i++) {
        HashMap<String, String> item = new HashMap<String, String>();

        String stopID = c.getString(stopIDIndex);
        String stopName = c.getString(stopDescIndex);
        String route = c.getString(routeIDIndex);
        String routeDesc = c.getString(routeDescIndex);
        Log.v(TAG, "PUT");
        Log.v(TAG, "stopID " + stopID + " stopName " + stopName);
        Log.v(TAG, "routeID " + route + " routeDesc" + routeDesc);
        item.put("stopID", stopID);
        item.put("stopName", stopName);
        item.put("routeID", route);
        item.put("routeDesc", routeDesc);
        c.moveToNext();
        locationList.add(item);
      }
      listAdapter.notifyDataSetChanged();
    }
  }
  public void setSavedBeaconsNotPinged() {
    Log.v(TAG, "didn't get a signal from a saved beacon");
    HashMap<String, String> nonActiveSavedDevices = new HashMap<String, String>(mHashNicknames);
    //  Loop through to get a hashmap of devices that are saved but we didn't get info for
    for (int i = 0; i < mIBeaconInfo.size(); i++) {
      iBeaconInfo temp = mIBeaconInfo.get(i);
      nonActiveSavedDevices.remove(temp.getHash());
      Log.v(TAG, "This is being removed: " + temp.getNickname());
    }

    //  Add the nonActiveSavedDevices to mIBeaconInfo
    if (nonActiveSavedDevices.size() > 0) {
      Iterator iter = nonActiveSavedDevices.entrySet().iterator();
      while (iter.hasNext()) {
        Map.Entry pairs = (Map.Entry) iter.next();

        iBeaconInfo device = new iBeaconInfo();
        device.setNickname(pairs.getValue().toString());
        device.setHash(pairs.getKey().toString());
        device.setDistance(getString(R.string.not_in_range_txt));
        mIBeaconInfo.add(device);
        Log.v(TAG, "not active beacon: " + device.getNickname());
      }
    }
  }