Example #1
0
 /** Called when the user selects the Send button */
 public void sendMessage(View view) {
   Intent intent = new Intent(this, DisplayMessageActivity.class);
   EditText editText = (EditText) findViewById(R.id.edit_message);
   String message = editText.getText().toString();
   intent.putExtra(EXTRA_MESSAGE, message);
   startActivity(intent);
 }
  void acctSelected(ServiceAcctInfo info) {
    Account acct = new Account();
    acct.name = info.desc;
    acct.service = info;

    DialogInterface.OnClickListener emptyClickListener =
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {}
        };

    AcctTables db = new AcctTables(this);
    try {
      db.openWritable();

      try {
        db.pushAccount(acct);
      } catch (SQLiteException e) {
        AlertDialog dlg =
            Utilities.buildAlert(
                this, e, "Unable to add account", "Internal Error", emptyClickListener);
        dlg.show();
        return;
      }
    } finally {
      db.close();
    }

    Intent i = getIntent();
    i.putExtra("acct_id", acct.ID);
    setResult(RESULT_OK, i);
    finish();
  }
Example #3
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.folderex);

    Intent gintent = getIntent();
    getPath = gintent.getStringExtra("path");
    dbPath = gintent.getStringExtra("dbpath");

    FileList _FileList = new FileList(this);
    _FileList.setOnPathChangedListener(_OnPathChanged);
    _FileList.setOnFileSelected(_OnFileSelected);

    LinearLayout layout = (LinearLayout) findViewById(R.id.LinearLayout01);
    layout.addView(_FileList);

    Util.print("getPath = " + getPath);
    String path = " ";

    if (getPath.equals("empty")) {
      File root = Environment.getExternalStorageDirectory();
      _FileList.setPath(root.getAbsolutePath());
      path = root.getAbsolutePath();
    } else {
      _FileList.setPath(getPath);
      path = getPath;
    }

    Util.print("path = " + path);

    _FileList.setFocusable(true);
    _FileList.setFocusableInTouchMode(true);

    ((TextView) findViewById(R.id.TextView01)).setSelected(true);
  }
        @Override
        public void onReceive(Context context, Intent intent) {
          final String action = intent.getAction();
          if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
            mConnected = true;
            updateConnectionState(R.string.connected);
            invalidateOptionsMenu();
          } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
            mConnected = false;
            updateConnectionState(R.string.disconnected);
            invalidateOptionsMenu();
          } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
            BluetoothGattService gattService = mBluetoothLeService.getSoftSerialService();
            characteristicTX = gattService.getCharacteristic(BluetoothLeService.UUID_HM_RX_TX);
            // characteristicRX = gattService.getCharacteristic(BluetoothLeService.UUID_HM_RX_TX);
            characteristicRX = characteristicTX;

            if ((gattService != null) && (characteristicTX != null)) {
              mBluetoothLeService.setCharacteristicNotification(characteristicTX, true);

              isSerial.setText("Serial ready");
              updateReadyState(R.string.ready);
            } else {
              isSerial.setText("Serial can't be found");
            }

          } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
            displayData(intent.getStringExtra(mBluetoothLeService.EXTRA_DATA));
          }
        }
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   RssItem item = rssList.get(position);
   Intent intent = new Intent(RssReaderActivity.this, RssDetailActivity.class);
   intent.putExtra("rss_title", item.getTitle());
   intent.putExtra("rss_link", item.getLink());
   RssReaderActivity.this.startActivity(intent);
 }
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.meat_toppings);
   Intent i = getIntent();
   size = i.getStringExtra("size");
   numVeggieToppings = i.getIntExtra("numVeggieToppings", 0);
   setMeatToppingsView();
   setNextButton();
 }
  /**
   * Shows <tt>AuthorizationRequestedDialog</tt> for the request with given <tt>id</tt>.
   *
   * @param id request identifier for which new dialog will be displayed.
   */
  public static void showDialog(Long id) {
    Context ctx = JitsiApplication.getGlobalContext();

    Intent showIntent = new Intent(ctx, AuthorizationRequestedDialog.class);

    showIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    showIntent.putExtra(EXTRA_REQUEST_ID, id);

    ctx.startActivity(showIntent);
  }
 @Override
 public void onItemClick(AdapterView<?> l, View v, int position, long id) {
   if (l.getId() == R.id.photosGridView) {
     String clickedItem = photosGridViewContents[position];
     Intent intent = new Intent(PhotoGridActivity.this, PhotoViewerActivity.class);
     intent.putExtra(
         "filename",
         clickedItem); // use putExtra method of Intent here for passing additional information to
                       // PhotoViewerActivity
     startActivity(intent);
   }
 }
  private void finishWithPath(String path) {
    if (pathSettingKey != null && !pathSettingKey.isEmpty()) {
      SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
      SharedPreferences.Editor editor = settings.edit();
      editor.putString(pathSettingKey, path);
      editor.commit();
    }

    Intent intent = new Intent();
    intent.putExtra("PATH", path);
    setResult(RESULT_OK, intent);
    finish();
  }
 @Override
 public void onClick(View v) {
   AnimationDrawable drawable = (AnimationDrawable) mIvScan.getBackground();
   if (drawable.isRunning()) {
     ToastUtils.show(getActivity(), "正在搜索中...");
   } else {
     drawable.start();
     Intent intent = new Intent(getActivity(), ScanService.class);
     intent.putExtras(new Bundle());
     SongManager.with(getActivity()).clearSong();
     updateList();
     getActivity().startService(intent);
   }
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == FILECHOOSER_RESULTCODE) { // found this from StackOverflow
     if (null == mUploadMessage) return;
     Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
     mUploadMessage.onReceiveValue(result);
     mUploadMessage = null;
   } else {
     // -----------I wrote this code below this line----------------------------------
     jpegData = intent.getExtras().getByteArray("image");
     Bitmap img = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
     Drawable d = new BitmapDrawable(img);
     profilePicture.setBackground(d);
   }
 }
Example #12
0
 public void doRestart() {
   try {
     String action = "org.mozilla.gecko.restart";
     Intent intent = new Intent(action);
     intent.setClassName(getPackageName(), getPackageName() + ".Restarter");
     addEnvToIntent(intent);
     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
     Log.i(LOG_FILE_NAME, intent.toString());
     GeckoAppShell.killAnyZombies();
     startActivity(intent);
   } catch (Exception e) {
     Log.i(LOG_FILE_NAME, "error doing restart", e);
   }
   finish();
   // Give the restart process time to start before we die
   GeckoAppShell.waitForAnotherGeckoProc();
 }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    int r = super.onStartCommand(intent, flags, startId);
    uid = intent.getExtras().getInt("uid");
    int pid = intent.getExtras().getInt("pid");
    cpuInfo = new CPUInfo(pid);
    memInfo = new MemoryInfo(pid);
    networkInfo = new NetworkInfo(uid);

    reset();

    floatingView = LayoutInflater.from(this).inflate(R.layout.monitor, null);
    txtTraffic = (TextView) floatingView.findViewById(R.id.traffic);
    txtCpu = (TextView) floatingView.findViewById(R.id.cpu);
    txtMem = (TextView) floatingView.findViewById(R.id.mem);

    floatingView
        .findViewById(R.id.reset)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                MonitorService.this.reset();
              }
            });

    floatingView
        .findViewById(R.id.close)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                handler.removeCallbacks(task);
                if (windowManager != null) windowManager.removeView(floatingView);
                windowManager = null;
              }
            });

    Log.e(App.TAG, "create floating window");

    createFloatingWindow();

    handler.postDelayed(task, 1000);
    return r;
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.receiver);

    final Button cancelbtn = (Button) findViewById(R.id.ButtonCancel);
    // cancelbtn.setEnabled(false);
    cancelbtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // streamtask.cancel(true);
            finish();
          }
        });

    try {
      Intent intent = getIntent();
      String action = intent.getAction();
      String type = intent.getType();

      if ((!(Intent.ACTION_SEND.equals(action))) || (type == null)) {
        throw new RuntimeException("Unknown intent action or type");
      }

      if (!("text/plain".equals(type))) {
        throw new RuntimeException("Type is not text/plain");
      }

      String extra = intent.getStringExtra(Intent.EXTRA_TEXT);
      if (extra == null) {
        throw new RuntimeException("Cannot get shared text");
      }

      final DownloadStreamTask streamtask = new DownloadStreamTask(this);

      //	Once created, a task is executed very simply:
      streamtask.execute(extra);

    } catch (Exception e) {
      Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
    }
  }
  // code which handles the action for each menu item
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.settings:
        {
          Intent preferences_intent = new Intent();
          preferences_intent.setComponent(
              new ComponentName(download_photos.this, preferences.class));
          preferences_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          getApplicationContext().startActivity(preferences_intent);

          return true;
        }
      case R.id.logout:
        {
          try {
            download_photos.this.facebook.logout(getApplicationContext());
          } catch (IOException e) {
            e.printStackTrace();
          }

          mPrefs = getSharedPreferences("COMMON", MODE_PRIVATE);

          SharedPreferences.Editor editor = mPrefs.edit();
          editor.putString("access_token", null);
          editor.putLong("access_expires", 0);
          editor.putBoolean("logout", true);
          editor.commit();
          finish();
          return true;
        }
      case R.id.about:
        {
          // shows our customized about dialog
          AboutDialog about = new AboutDialog(this);

          about.show();
          return true;
        }
        // lets deal with default case
      default:
        return super.onOptionsItemSelected(item);
    }
  }
Example #16
0
  public String showFilePicker(String aMimeType) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(aMimeType);
    GeckoApp.this.startActivityForResult(
        Intent.createChooser(intent, getString(R.string.choose_file)), FILE_PICKER_REQUEST);
    String filePickerResult = "";

    try {
      while (null == (filePickerResult = mFilePickerResult.poll(1, TimeUnit.MILLISECONDS))) {
        Log.i("GeckoApp", "processing events from showFilePicker ");
        GeckoAppShell.processNextNativeEvent();
      }
    } catch (InterruptedException e) {
      Log.i(LOG_FILE_NAME, "showing file picker ", e);
    }

    return filePickerResult;
  }
Example #17
0
  @Override
  protected void onNewIntent(Intent intent) {
    if (checkLaunchState(LaunchState.GeckoExiting)) {
      // We're exiting and shouldn't try to do anything else just incase
      // we're hung for some reason we'll force the process to exit
      System.exit(0);
      return;
    }
    final String action = intent.getAction();
    if (ACTION_DEBUG.equals(action)
        && checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) {

      mMainHandler.postDelayed(
          new Runnable() {
            public void run() {
              Log.i(LOG_FILE_NAME, "Launching from debug intent after 5s wait");
              setLaunchState(LaunchState.Launching);
              launch(null);
            }
          },
          1000 * 5 /* 5 seconds */);
      Log.i(LOG_FILE_NAME, "Intent : ACTION_DEBUG - waiting 5s before launching");
      return;
    }
    if (checkLaunchState(LaunchState.WaitForDebugger) || launch(intent)) return;

    if (Intent.ACTION_MAIN.equals(action)) {
      Log.i(LOG_FILE_NAME, "Intent : ACTION_MAIN");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(""));
    } else if (Intent.ACTION_VIEW.equals(action)) {
      String uri = intent.getDataString();
      GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
      Log.i(LOG_FILE_NAME, "onNewIntent: " + uri);
    } else if (ACTION_WEBAPP.equals(action)) {
      String uri = intent.getStringExtra("args");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
      Log.i(LOG_FILE_NAME, "Intent : WEBAPP - " + uri);
    } else if (ACTION_BOOKMARK.equals(action)) {
      String args = intent.getStringExtra("args");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(args));
      Log.i(LOG_FILE_NAME, "Intent : BOOKMARK - " + args);
    }
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {
      String sdStatus = Environment.getExternalStorageState();
      if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
        Log.i("TestFile", "SD card is not avaiable/writeable right now.");
        return;
      }
      String name =
          new DateFormat().format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg";
      Toast.makeText(this, name, Toast.LENGTH_LONG).show();
      Bundle bundle = data.getExtras();
      Bitmap bitmap = (Bitmap) bundle.get("data"); // 获取相机返回的数据,并转换为Bitmap图片格式

      FileOutputStream b = null;
      File file = new File("/sdcard/myImage/");
      if (!file.exists()) file.mkdirs(); // 创建文件夹

      String fileName = "/sdcard/myImage/" + name;
      File photofile = new File(fileName);
      if (!photofile.exists()) {
        try {
          photofile.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      try {
        b = new FileOutputStream(photofile);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, b); // 把数据写入文件
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        try {
          b.flush();
          b.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      // 动态的改变gridview中的一个Item的内容
      bitmapList.set(currentIndex, bitmap);
      myGalleryAdapter.notifyDataSetChanged();
      updatePhoto(
          Long.valueOf(phoneNumberToId.get(phoneNumber.get(currentIndex))), bitmapToBytes(bitmap));
      //            ((ImageView) findViewById(R.id.imageView)).setImageBitmap(bitmap);//
      // 将图片显示在ImageView里
      Intent intent = new Intent(ContactActivity.this, ContactActivity.class);
      this.startActivity(intent);
      this.finish();
    }
  }
Example #19
0
 public void addEnvToIntent(Intent intent) {
   Map<String, String> envMap = System.getenv();
   Set<Map.Entry<String, String>> envSet = envMap.entrySet();
   Iterator<Map.Entry<String, String>> envIter = envSet.iterator();
   int c = 0;
   while (envIter.hasNext()) {
     Map.Entry<String, String> entry = envIter.next();
     intent.putExtra("env" + c, entry.getKey() + "=" + entry.getValue());
     c++;
   }
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == GET_SESSION) {
     if (resultCode == RESULT_CANCELED) {
       cancel();
     } else {
       int sessionId = data.getIntExtra("sess_id", 0);
       loadContext(sessionId);
     }
   }
 }
 @Override
 public void onNewIntent(Intent intent) {
   try {
     if (intent.getExtras().getBoolean("rss_update")) {
       rssFeed = dbQuery.getUpdatedRssFeed();
       updateListView();
     }
   } catch (NullPointerException e) {
     e.printStackTrace();
   }
 }
Example #22
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    String filePickerResult = "";
    if (data != null && resultCode == RESULT_OK) {
      try {
        ContentResolver cr = getContentResolver();
        Uri uri = data.getData();
        Cursor cursor =
            GeckoApp.mAppContext
                .getContentResolver()
                .query(uri, new String[] {OpenableColumns.DISPLAY_NAME}, null, null, null);
        String name = null;
        if (cursor != null) {
          try {
            if (cursor.moveToNext()) {
              name = cursor.getString(0);
            }
          } finally {
            cursor.close();
          }
        }
        String fileName = "tmp_";
        String fileExt = null;
        int period;
        if (name == null || (period = name.lastIndexOf('.')) == -1) {
          String mimeType = cr.getType(uri);
          fileExt = "." + GeckoAppShell.getExtensionFromMimeType(mimeType);
        } else {
          fileExt = name.substring(period);
          fileName = name.substring(0, period);
        }
        File file = File.createTempFile(fileName, fileExt, sGREDir);

        FileOutputStream fos = new FileOutputStream(file);
        InputStream is = cr.openInputStream(uri);
        byte[] buf = new byte[4096];
        int len = is.read(buf);
        while (len != -1) {
          fos.write(buf, 0, len);
          len = is.read(buf);
        }
        fos.close();
        filePickerResult = file.getAbsolutePath();
      } catch (Exception e) {
        Log.e(LOG_FILE_NAME, "showing file picker", e);
      }
    }
    try {
      mFilePickerResult.put(filePickerResult);
    } catch (InterruptedException e) {
      Log.i(LOG_FILE_NAME, "error returning file picker result", e);
    }
  }
Example #23
0
  public void mOnClickSave(View v) {
    String inputPath = nowPath;
    UseDb db = new UseDb();

    File files = new File(inputPath);
    if (files.exists() == true) {
      db.setValue(this, dbPath, nowPath);

      Intent intent = new Intent(this, Loading.class);
      intent.putExtra("path", nowPath);
      startActivity(intent);

      finish();
    } else {
      Toast.makeText(
              FolderEx.this,
              getResources().getString(R.string.sp_msg_notexistfolder),
              Toast.LENGTH_SHORT)
          .show();
    }
  }
Example #24
0
  @Override
  protected void onNewIntent(Intent intent) {
    OrientationUtil.setOrientation(this, intent);

    if (!Intent.ACTION_SEARCH.equals(intent.getAction())) {
      return;
    }
    String pattern = intent.getStringExtra(SearchManager.QUERY);
    myBookmarkSearchPatternOption.setValue(pattern);

    final LinkedList<Bookmark> bookmarks = new LinkedList<Bookmark>();
    pattern = pattern.toLowerCase();
    for (Bookmark b : myAllBooksAdapter.bookmarks()) {
      if (MiscUtil.matchesIgnoreCase(b.getText(), pattern)) {
        bookmarks.add(b);
      }
    }
    if (!bookmarks.isEmpty()) {
      showSearchResultsTab(bookmarks);
    } else {
      UIUtil.showErrorMessage(this, "bookmarkNotFound");
    }
  }
Example #25
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (resultCode == RESULT_OK) {
     path = data.getData().getPath();
     FileInputStream fis = null;
     try {
       // Generate md5
       fis = new FileInputStream(path);
       String md5String = new String(Hex.encodeHex(DigestUtils.md5(fis)));
       text.setText(md5String);
     } catch (FileNotFoundException e) {
       e.printStackTrace();
     } catch (IOException io) {
       io.printStackTrace();
     }
   }
 }
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   switch (requestCode) {
     case REQ_RSS_MANAGE:
       switch (resultCode) {
         case RES_RSS_ADD:
           String[] addProvider = data.getStringArrayExtra("add-provider");
           loadData(addProvider[0], false, true, true);
           curProvider = dbQuery.getRssProviderList(null).length() - 1;
           break;
         case RES_RSS_DELETE:
           loadData(null, true, false, false);
           break;
         default:
           break;
       }
       break;
     default:
       break;
   }
 }
Example #27
0
  @Override
  protected void onCreate(Bundle icicle) {

    Log.d("GODOT", "** GODOT ACTIVITY CREATED HERE ***\n");

    super.onCreate(icicle);
    _self = this;
    Window window = getWindow();
    window.addFlags(
        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // check for apk expansion API
    if (true) {
      boolean md5mismatch = false;
      command_line = getCommandLine();
      boolean use_apk_expansion = false;
      String main_pack_md5 = null;
      String main_pack_key = null;

      List<String> new_args = new LinkedList<String>();

      for (int i = 0; i < command_line.length; i++) {

        boolean has_extra = i < command_line.length - 1;
        if (command_line[i].equals("-use_apk_expansion")) {
          use_apk_expansion = true;
        } else if (has_extra && command_line[i].equals("-apk_expansion_md5")) {
          main_pack_md5 = command_line[i + 1];
          i++;
        } else if (has_extra && command_line[i].equals("-apk_expansion_key")) {
          main_pack_key = command_line[i + 1];
          SharedPreferences prefs = getSharedPreferences("app_data_keys", MODE_PRIVATE);
          Editor editor = prefs.edit();
          editor.putString("store_public_key", main_pack_key);

          editor.commit();
          i++;
        } else if (command_line[i].trim().length() != 0) {
          new_args.add(command_line[i]);
        }
      }

      if (new_args.isEmpty()) {
        command_line = null;
      } else {

        command_line = new_args.toArray(new String[new_args.size()]);
      }
      if (use_apk_expansion && main_pack_md5 != null && main_pack_key != null) {
        // check that environment is ok!
        if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
          Log.d("GODOT", "**ERROR! No media mounted!");
          // show popup and die
        }

        // Build the full path to the app's expansion files
        try {
          expansion_pack_path =
              Environment.getExternalStorageDirectory().toString()
                  + "/Android/obb/"
                  + this.getPackageName();
          expansion_pack_path +=
              "/"
                  + "main."
                  + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode
                  + "."
                  + this.getPackageName()
                  + ".obb";
        } catch (Exception e) {
          e.printStackTrace();
        }

        File f = new File(expansion_pack_path);

        boolean pack_valid = true;
        Log.d("GODOT", "**PACK** - Path " + expansion_pack_path);

        if (!f.exists()) {

          pack_valid = false;
          Log.d("GODOT", "**PACK** - File does not exist");

        } else if (obbIsCorrupted(expansion_pack_path, main_pack_md5)) {
          Log.d("GODOT", "**PACK** - Expansion pack (obb) is corrupted");
          pack_valid = false;
          try {
            f.delete();
          } catch (Exception e) {
            Log.d("GODOT", "**PACK** - Error deleting corrupted expansion pack (obb)");
          }
        }

        if (!pack_valid) {
          Log.d("GODOT", "Pack Invalid, try re-downloading.");

          Intent notifierIntent = new Intent(this, this.getClass());
          notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

          PendingIntent pendingIntent =
              PendingIntent.getActivity(this, 0, notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT);

          int startResult;
          try {
            Log.d("GODOT", "INITIALIZING DOWNLOAD");
            startResult =
                DownloaderClientMarshaller.startDownloadServiceIfRequired(
                    getApplicationContext(), pendingIntent, GodotDownloaderService.class);
            Log.d("GODOT", "DOWNLOAD SERVICE FINISHED:" + startResult);

            if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
              Log.d("GODOT", "DOWNLOAD REQUIRED");
              // This is where you do set up to display the download
              // progress (next step)
              mDownloaderClientStub =
                  DownloaderClientMarshaller.CreateStub(this, GodotDownloaderService.class);

              setContentView(com.godot.game.R.layout.downloading_expansion);
              mPB = (ProgressBar) findViewById(com.godot.game.R.id.progressBar);
              mStatusText = (TextView) findViewById(com.godot.game.R.id.statusText);
              mProgressFraction = (TextView) findViewById(com.godot.game.R.id.progressAsFraction);
              mProgressPercent = (TextView) findViewById(com.godot.game.R.id.progressAsPercentage);
              mAverageSpeed = (TextView) findViewById(com.godot.game.R.id.progressAverageSpeed);
              mTimeRemaining = (TextView) findViewById(com.godot.game.R.id.progressTimeRemaining);
              mDashboard = findViewById(com.godot.game.R.id.downloaderDashboard);
              mCellMessage = findViewById(com.godot.game.R.id.approveCellular);
              mPauseButton = (Button) findViewById(com.godot.game.R.id.pauseButton);
              mWiFiSettingsButton = (Button) findViewById(com.godot.game.R.id.wifiSettingsButton);

              return;
            } else {
              Log.d("GODOT", "NO DOWNLOAD REQUIRED");
            }
          } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            Log.d("GODOT", "Error downloading expansion package:" + e.getMessage());
          }
        }
      }
    }

    initializeGodot();

    //	instanceSingleton( new GodotFacebook(this) );

  }
 void loginFailure() {
   Intent loginProf = new Intent(this, Login.class);
   loginProf.putExtra("prof_id", profileId);
   if (this.session != null) loginProf.putExtra("sess_id", this.session.ID);
   startActivityForResult(loginProf, GET_SESSION);
 }
  public void onCreate() {
    int flags, screenLightVal = 1;
    Sensor mSensor;
    List<Sensor> sensors;

    if (scanData == null) return; // no ScanData, not possible to run correctly...

    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
    SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    try {
      screenLightVal = Integer.parseInt(SP.getString("screenLight", "2"));
    } catch (NumberFormatException nfe) {
    }
    if (screenLightVal == 1) flags = PowerManager.PARTIAL_WAKE_LOCK;
    else if (screenLightVal == 3) flags = PowerManager.FULL_WAKE_LOCK;
    else flags = PowerManager.SCREEN_DIM_WAKE_LOCK;
    wl = pm.newWakeLock(flags, "OpenWLANMap");
    wl.acquire();
    while (myWLocate == null) {
      try {
        myWLocate = new MyWLocate(this);
        break;
      } catch (IllegalArgumentException iae) {
        myWLocate = null;
      }
      try {
        Thread.sleep(100);
      } catch (InterruptedException ie) {
      }
    }

    try {
      scanData.setUploadThres(Integer.parseInt(SP.getString("autoUpload", "0")));
    } catch (NumberFormatException nfe) {
    }
    try {
      scanData.setNoGPSExitInterval(
          Integer.parseInt(SP.getString("noGPSExitInterval", "0")) * 60 * 1000);
    } catch (NumberFormatException nfe) {
    }

    Intent intent = new Intent(this, OWMapAtAndroid.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);

    notification =
        new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.icon)
            .setContentTitle(getResources().getText(R.string.app_name))
            .setContentText("")
            .setContentIntent(pendIntent)
            .build();

    notification.flags |= Notification.FLAG_NO_CLEAR;
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    startForeground(1703, notification);

    getScanData().setService(this);
    getScanData().setmView(new HUDView(this));
    getScanData().getmView().setValue(getScanData().incStoredValues());
    WindowManager.LayoutParams params =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.LEFT | Gravity.BOTTOM;
    params.setTitle("Load Average");
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(getScanData().getmView(), params);

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    sensorManager.registerListener(
        this,
        sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
        SensorManager.SENSOR_DELAY_GAME);
    sensorManager.registerListener(
        this,
        sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
        SensorManager.SENSOR_DELAY_GAME);
    sensors = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
    mSensor = sensors.get(0);
    getScanData().getTelemetryData().setAccelMax(mSensor.getMaximumRange());
    telemetryDir = Environment.getExternalStorageDirectory().getPath() + "/telemetry/";
    File dir = new File(telemetryDir);
    dir.mkdir();

    connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    mConnectionState = (TextView) findViewById(R.id.connection_state);
    // is serial present?
    isSerial = (TextView) findViewById(R.id.isSerial);

    msgEdit = (EditText) findViewById(R.id.editText);
    returnText = (TextView) findViewById(R.id.returnText);

    sendButton = (Button) findViewById(R.id.sendButton);
    //        timeButton = (Button) findViewById(R.id.timeButton);

    sendButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (characteristicReady) {
              StringBuffer sb = new StringBuffer("m");
              sb.append(msgEdit.getText()).append("\n");

              sendMessage(sb.toString());
            }
          }
        });

    //        timeButton.setOnClickListener(new View.OnClickListener() {
    //
    //            @Override
    //            public void onClick(View v) {
    //                if (characteristicReady) {
    //                    StringBuffer sb = new StringBuffer("t");
    //                    Date now = new Date();
    //                    sb.append(DATE_FORMAT.format(now)).append("\n");
    //
    //                    sendMessage(sb.toString());
    //                }
    //            }
    //        });

    infoButton = (ImageView) findViewById(R.id.infoImage);
    infoButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            iascDialog();
          }
        });

    mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
    mSurfaceHolder = mSurfaceView.getHolder();
    mSurfaceHolder.addCallback(new MyHolder());

    mPaint = new Paint();
    // 画笔的粗细
    mPaint.setStrokeWidth(5.0f);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
  }