// NOTE: Implement any IChildProcessService methods here.
 @Override
 public int setupConnection(Bundle args, IChildProcessCallback callback) {
   mCallback = callback;
   // Required to unparcel FileDescriptorInfo.
   args.setClassLoader(getClassLoader());
   synchronized (mMainThread) {
     // Allow the command line to be set via bind() intent or setupConnection, but
     // the FD can only be transferred here.
     if (mCommandLineParams == null) {
       mCommandLineParams = args.getStringArray(ChildProcessConnection.EXTRA_COMMAND_LINE);
     }
     // We must have received the command line by now
     assert mCommandLineParams != null;
     mCpuCount = args.getInt(ChildProcessConnection.EXTRA_CPU_COUNT);
     mCpuFeatures = args.getLong(ChildProcessConnection.EXTRA_CPU_FEATURES);
     assert mCpuCount > 0;
     Parcelable[] fdInfosAsParcelable =
         args.getParcelableArray(ChildProcessConnection.EXTRA_FILES);
     // For why this arraycopy is necessary:
     // http://stackoverflow.com/questions/8745893/i-dont-get-why-this-classcastexception-occurs
     mFdInfos = new FileDescriptorInfo[fdInfosAsParcelable.length];
     System.arraycopy(fdInfosAsParcelable, 0, mFdInfos, 0, fdInfosAsParcelable.length);
     Bundle sharedRelros = args.getBundle(Linker.EXTRA_LINKER_SHARED_RELROS);
     if (sharedRelros != null) {
       Linker.getInstance().useSharedRelros(sharedRelros);
       sharedRelros = null;
     }
     mMainThread.notifyAll();
   }
   return Process.myPid();
 }
Exemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(
        TAG,
        getClass().getSimpleName()
            + ".onCreate ("
            + hashCode()
            + "): "
            + (savedInstanceState != null));

    ApiCompatUtil compatUtil = ApiCompatUtil.getInstance();
    compatUtil.requestWindowFeatures(this);
    setContentView(R.layout.prime);
    compatUtil.setWindowFeatures(this);

    compatUtil.setupActionBar(this);

    int curTab = DEFAULT_TAB;

    if (savedInstanceState != null) {
      Bundle fragData = savedInstanceState.getBundle("fragData");
      if (fragData != null) {
        Log.d(TAG, "MainActivity.onCreate: got fragData!");
        for (String key : fragData.keySet()) {
          Log.d(TAG, "  fragData key: " + key);
          if (!m_fragData.containsKey(key)) m_fragData.putBundle(key, fragData.getBundle(key));
        }
      }

      curTab = savedInstanceState.getInt(PrefKey.opentab.name(), DEFAULT_TAB);
    }

    boolean upgraded = false;
    if (savedInstanceState != null) {
      //      setCurrentTab(savedInstanceState.getInt(PrefKey.opentab.name(), -1));
    } else {
      Resources resources = getResources();
      SharedPreferences p = StaticUtils.getApplicationPreferences(this);
      upgraded = StaticUtils.checkUpgrade(this);
      if (!readInstanceState(this)) setInitialState();
      if (PrefKey.sync_on_open.getBoolean(p, resources)) {
        WeaveAccountInfo loginInfo = StaticUtils.getLoginInfo(this);
        if (upgraded || loginInfo == null) {
          StaticUtils.requestSync(this, m_handler);
        }
      }
    }

    FragmentManager fm = getSupportFragmentManager();
    // You can find Fragments just like you would with a View by using FragmentManager.
    Fragment fragment = fm.findFragmentById(R.id.fragment_content);

    // If we are using activity_fragment_xml.xml then this the fragment will not be null, otherwise
    // it will be.
    if (fragment == null) {
      setMyFragment(new MiscListFragment(), false);
    }
  }
Exemplo n.º 3
0
 public void b(Class class1, Bundle bundle) {
   if (ml.getBundle("com.google.android.gms.ads.mediation.customevent.CustomEventAdapter")
       == null) {
     ml.putBundle(
         "com.google.android.gms.ads.mediation.customevent.CustomEventAdapter", new Bundle());
   }
   ml.getBundle("com.google.android.gms.ads.mediation.customevent.CustomEventAdapter")
       .putBundle(class1.getName(), bundle);
 }
Exemplo n.º 4
0
 public Bundle getCustomEventExtrasBundle(Class class1) {
   Bundle bundle =
       ml.getBundle("com.google.android.gms.ads.mediation.customevent.CustomEventAdapter");
   if (bundle != null) {
     return bundle.getBundle(class1.getClass().getName());
   } else {
     return null;
   }
 }
Exemplo n.º 5
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   if (null != savedInstanceState && null != savedInstanceState.getBundle("savebundle")) {
     getIntent().putExtras(savedInstanceState.getBundle("savebundle"));
     getIntent().putExtra("savedInstanceState", true);
   }
   registerFinishReceiver();
   registerReLoginReceiver();
 }
 /**
  * Compare two {@link Intent}s.
  *
  * @param i1 first intent
  * @param i2 second intent
  * @return true if both intents describe the same command
  */
 public static boolean equals(final Intent i1, final Intent i2) {
   Bundle b1 = i1.getExtras();
   Bundle b2 = i2.getExtras();
   if (b1 == null || b2 == null) {
     return false;
   }
   b1 = b1.getBundle(EXTRAS_COMMAND);
   b2 = b2.getBundle(EXTRAS_COMMAND);
   if (b1 == null || b2 == null) {
     return false;
   }
   final short s1 = b1.getShort(TYPE);
   final short s2 = b2.getShort(TYPE);
   return s1 == s2;
 }
Exemplo n.º 7
0
  // Tries to load an existing analysis.
  public static ExperimentAnalysis.AnalysisEntry loadSensorAnalysis(
      File storageDir, List<ISensorData> allSensorData) {
    // try to load old analysis
    File projectFile = new File(storageDir, IDataAnalysis.EXPERIMENT_ANALYSIS_FILE_NAME);
    Bundle bundle = loadBundleFromFile(projectFile);
    if (bundle == null) return null;

    Bundle analysisDataBundle = bundle.getBundle(USED_DATA_KEY);
    if (analysisDataBundle == null) return null;

    int[] integerList = bundle.getIntArray(SENSOR_DATA_LIST_KEY);
    ISensorData[] dataList = new ISensorData[integerList.length];
    for (int i = 0; i < dataList.length; i++) dataList[i] = allSensorData.get(integerList[i]);

    String analysisPluginId = bundle.getString(PLUGIN_ID_KEY);
    ExperimentPluginFactory factory = ExperimentPluginFactory.getFactory();
    IAnalysisPlugin plugin = factory.findAnalysisPlugin(analysisPluginId);
    IDataAnalysis dataAnalysis = plugin.createDataAnalysis(dataList);

    if (!dataAnalysis.loadAnalysisData(analysisDataBundle, storageDir)) return null;

    String analysisUid = bundle.getString(ANALYSIS_UID_KEY);

    return new ExperimentAnalysis.AnalysisEntry(dataAnalysis, analysisUid, plugin, storageDir);
  }
Exemplo n.º 8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.incident_tab);
    new Handler();
    bundle = new Bundle();
    extras = this.getIntent().getExtras();

    activityTitle = (TextView) findViewById(R.id.title_text);

    tabHost = getTabHost();

    // load preferences
    checkinEnabled();

    tabHost.setCurrentTab(0);

    // set tab colors
    final int tabSelectedColor = getResources().getColor(R.color.tab_selected_color);
    final int tabUnselectedColor = getResources().getColor(R.color.tab_unselected_color);
    setTabColor(tabHost, tabSelectedColor, tabUnselectedColor);

    // set tab colors on tab change as well
    tabHost.setOnTabChangedListener(
        new OnTabChangeListener() {
          public void onTabChanged(String arg0) {
            setTabColor(tabHost, tabSelectedColor, tabUnselectedColor);
          }
        });

    if (extras != null) {
      bundle = extras.getBundle("tab");
      tabHost.setCurrentTab(bundle.getInt("tab_index"));
    }
  }
Exemplo n.º 9
0
  /**
   * Called when Activity is first created. Turns off the title bar, sets up the content views, and
   * fires up the SnakeView.
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.snake_layout);

    mSnakeView = (SnakeView) findViewById(R.id.snake);

    mSnakeView.setDependentViews(
        (TextView) findViewById(R.id.text),
        findViewById(R.id.arrowContainer),
        findViewById(R.id.background));

    // Instantiate the gesture detector with the
    // application context and an implementation of
    // GestureDetector.OnGestureListener
    mDetector = new GestureDetectorCompat(this, new SnakeGesture());
    // Set the gesture detector as the double tap
    // listener.
    mDetector.setOnDoubleTapListener(new DoubleTap());

    if (savedInstanceState == null) {
      // We were just launched -- set up a new game
      mSnakeView.setMode(SnakeView.READY);
    } else {
      // We are being restored
      Bundle map = savedInstanceState.getBundle(ICICLE_KEY);
      if (map != null) {
        mSnakeView.restoreState(map);
      } else {
        mSnakeView.setMode(SnakeView.PAUSE);
      }
    }
  }
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.edit_slide_duration);

    int dur;
    if (icicle == null) {
      // Get extra from intent.
      Intent intent = getIntent();
      mCurSlide = intent.getIntExtra(SLIDE_INDEX, 1);
      mTotal = intent.getIntExtra(SLIDE_TOTAL, 1);
      dur = intent.getIntExtra(SLIDE_DUR, 8);
    } else {
      mState = icicle.getBundle(STATE);

      mCurSlide = mState.getInt(SLIDE_INDEX, 1);
      mTotal = mState.getInt(SLIDE_TOTAL, 1);
      dur = mState.getInt(SLIDE_DUR, 8);
    }

    // Label.
    mLabel = (TextView) findViewById(R.id.label);
    mLabel.setText(
        getString(R.string.duration_selector_title) + " " + (mCurSlide + 1) + "/" + mTotal);

    // Input text field.
    mDur = (EditText) findViewById(R.id.text);
    mDur.setText(String.valueOf(dur));
    mDur.setOnKeyListener(mOnKeyListener);

    // Done button.
    mDone = (Button) findViewById(R.id.done);
    mDone.setOnClickListener(mOnDoneClickListener);
  }
Exemplo n.º 11
0
 private boolean isIncognito(long id, Bundle state) {
   Bundle tabstate = state.getBundle(Long.toString(id));
   if ((tabstate != null) && !tabstate.isEmpty()) {
     return tabstate.getBoolean(Tab.INCOGNITO);
   }
   return false;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_input_form);

    loadTheme();

    findViews();

    steps = onCreateSteps();

    if (savedInstanceState != null) {
      setupData = savedInstanceState.getBundle(KEY_DATA);
      stepIndex = savedInstanceState.getInt(KEY_STEP_INDEX, 0);
    }

    setupTitle();
    setupInput();
    setupError();
    setupDetails();

    nextButton.setOnClickListener(nextButtonClickListener);
    errorSwitcher.setText("");
    updateStep();
  }
Exemplo n.º 13
0
 public void requestBannerAd(
     Context context,
     MediationBannerListener mediationbannerlistener,
     Bundle bundle,
     AdSize adsize,
     MediationAdRequest mediationadrequest,
     Bundle bundle1) {
   zzJG = (CustomEventBanner) zzj(bundle.getString("class_name"));
   if (zzJG == null) {
     mediationbannerlistener.onAdFailedToLoad(this, 0);
     return;
   }
   if (bundle1 == null) {
     bundle1 = null;
   } else {
     bundle1 = bundle1.getBundle(bundle.getString("class_name"));
   }
   zzJG.requestBannerAd(
       context,
       new zza(this, mediationbannerlistener),
       bundle.getString("parameter"),
       adsize,
       mediationadrequest,
       bundle1);
 }
Exemplo n.º 14
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    result = savedInstanceState == null ? new Bundle() : savedInstanceState.getBundle(EXTRA_RESULT);

    addPreferencesFromResource(R.xml.preferences_reminders);

    if (preJellybean()) {
      getPreferenceScreen()
          .removePreference(findPreference(getString(R.string.p_rmd_notif_actions_enabled)));
    }

    if (deviceInfo.supportsLocationServices()) {
      setExtraOnChange(R.string.p_geofence_radius, RESET_GEOFENCES);
      setExtraOnChange(R.string.p_geofence_responsiveness, RESET_GEOFENCES);
      setExtraOnChange(R.string.p_geofence_reminders_enabled, TOGGLE_GEOFENCES);
    } else {
      getPreferenceScreen()
          .removePreference(findPreference(getString(R.string.geolocation_reminders)));
    }

    initializeRingtonePreference();
    initializeTimePreference(getDefaultRemindTimePreference(), REQUEST_DEFAULT_REMIND);
    initializeTimePreference(getQuietStartPreference(), REQUEST_QUIET_START);
    initializeTimePreference(getQuietEndPreference(), REQUEST_QUIET_END);
  }
  /**
   * The IntentService calls this method from the default worker thread with the intent that started
   * the service. When this method returns, IntentService stops the service, as appropriate.
   */
  @Override
  protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras == null) {
      Log.e(Constants.TAG, "Extras bundle is null!");
      return;
    }

    if (!(extras.containsKey(EXTRA_ACTION))) {
      Log.e(Constants.TAG, "Extra bundle must contain an action!");
      return;
    }

    if (extras.containsKey(EXTRA_MESSENGER)) {
      mMessenger = (Messenger) extras.get(EXTRA_MESSENGER);
    }
    Bundle data = extras.getBundle(EXTRA_DATA);

    int action = extras.getInt(EXTRA_ACTION);

    setProgressCircleWithHandler(true);

    // execute action from extra bundle
    switch (action) {
      case ACTION_CHANGE_COLOR:
        int newColor = data.getInt(CHANGE_COLOR_NEW_COLOR);

        // only if enabled
        if (new AccountHelper(this).isAccountActivated()) {
          // update calendar color
          CalendarSyncAdapterService.updateCalendarColor(this, newColor);
        }

        break;

      case ACTION_CHANGE_REMINDER:
        int newMinutes = data.getInt(CHANGE_REMINDER_NEW_MINUTES);
        int reminderNo = data.getInt(CHANGE_REMINDER_NO);

        // only if enabled
        if (new AccountHelper(this).isAccountActivated()) {
          // Update all reminders to new minutes
          CalendarSyncAdapterService.updateAllReminders(this, reminderNo, newMinutes);
        }

        break;

      case ACTION_MANUAL_SYNC:

        // Force synchronous sync
        CalendarSyncAdapterService.performSync(this);

        break;

      default:
        break;
    }

    setProgressCircleWithHandler(false);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_input_form);

    loadTheme();

    sSteps = getSteps(this);
    sStepOptional = getOptionalSteps(this);

    findViews();

    if (savedInstanceState != null) {
      setupData = savedInstanceState.getBundle(KEY_DATA);
      mStepIndex = savedInstanceState.getInt(KEY_STEP_INDEX, 0);
    }

    setupTitle();
    setupInput();
    setupError();
    setupDetails();

    mNextButton.setOnClickListener(mOnNextButtonClickListener);
    mErrorSwitcher.setText("");

    Step step = getCurrentStep();
    if (step != null && step instanceof TextStep) {
      try {
        ((TextStep) step).getView().setOnEditorActionListener(mOnEnterPressListener);
      } catch (Exception e) {
      }
    }
    updateStep();
  }
 public void a(Bundle paramBundle)
 {
   int n = 0;
   if (paramBundle != null)
   {
     d.addAll((ArrayList)paramBundle.getSerializable("contact_details"));
     h = paramBundle.getInt("selector_dialog_title_id", 0);
     i = null;
     paramBundle = paramBundle.getBundle("selector_dialog_choices");
     if (paramBundle != null)
     {
       i = new ArrayList(paramBundle.size());
       while (n < paramBundle.size())
       {
         i.add((fac)paramBundle.getSerializable(11 + n));
         n += 1;
       }
     }
     if ((h > 0) && (i != null) && (i.size() > 1))
     {
       paramBundle = l.a(m);
       bz localbz = l.a();
       if (paramBundle != null) {
         localbz.a(paramBundle);
       }
       g = ((fab)ilh.a(e, fab.class)).a(e.getResources().getString(h), i);
       g.a(j);
       g.a(localbz, m);
     }
   }
 }
Exemplo n.º 18
0
 private void init() {
   bundle = getIntent().getExtras();
   if (bundle != null) {
     if (bundle.containsKey("fragmentName")) {
       fragmentName = bundle.getString("fragmentName");
     }
     if (bundle.containsKey("title")) {
       title = bundle.getString("title");
     }
     if (bundle.containsKey("parameters")) {
       parameters = bundle.getBundle("parameters");
     }
   }
   if (fragmentName.length() > 0) {
     try {
       fragment = (Fragment) Class.forName(fragmentName).newInstance();
       if (parameters != null) {
         fragment.setArguments(parameters);
       }
     } catch (InstantiationException e) {
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       e.printStackTrace();
     } catch (ClassNotFoundException e) {
       e.printStackTrace();
     }
   }
 }
 @Override
 public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
   super.onViewStateRestored(savedInstanceState);
   if (savedInstanceState != null) {
     Bundle inState = savedInstanceState.getBundle(TAG);
     putCurrentState(inState);
   }
 }
 /**
  * Create Command from {@link Intent}.
  *
  * @param i Intent
  */
 public ConnectorCommand(final Intent i) {
   Bundle e = i.getExtras();
   if (e != null) {
     this.bundle = e.getBundle(EXTRAS_COMMAND);
   } else {
     this.bundle = new Bundle();
   }
 }
Exemplo n.º 21
0
 public synchronized void u(Bundle bundle) {
     if (bundle != null) {
         ry.V(bundle.getBoolean("use_contactables_api", true));
         rm.aCt.t(bundle);
         aCy = bundle.getBundle("config.email_type_map");
         aCz = bundle.getBundle("config.phone_type_map");
     }
 }
 @Override
 public void onRestoreInstanceState(Bundle savedInstanceState) {
   super.onSaveInstanceState(savedInstanceState);
   if (savedInstanceState != null) {
     setupData = savedInstanceState.getBundle(KEY_DATA);
     mStepIndex = savedInstanceState.getInt(KEY_STEP_INDEX, 0);
   }
 }
Exemplo n.º 23
0
 @Override
 protected void onRestoreInstanceState(Bundle loadState) {
   super.onRestoreInstanceState(loadState);
   // use this to load your snacks for later
   mSnackBar.onRestoreInstanceState(loadState.getBundle(SAVED_SNACKBAR));
   // might as well load the counter too
   mSnackIndex = loadState.getInt(SAVED_COUNT);
 }
Exemplo n.º 24
0
  public static Bundle getSuccessResultsFromIntent(Intent resultIntent) {
    int version = getProtocolVersionFromIntent(resultIntent);
    Bundle extras = resultIntent.getExtras();
    if (!isVersionCompatibleWithBucketedIntent(version) || extras == null) {
      return extras;
    }

    return extras.getBundle(EXTRA_PROTOCOL_METHOD_RESULTS);
  }
Exemplo n.º 25
0
 public void restoreState(Bundle inState) {
   int stackSize = inState.getInt("cmdStack.size");
   for (int i = 0; i < stackSize; i++) {
     Bundle commandState = inState.getBundle("cmdStack." + i);
     AbstractCommand command = AbstractCommand.newInstance(commandState.getString("commandClass"));
     command.restoreState(commandState);
     push(command);
   }
 }
Exemplo n.º 26
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // The preferences returned if the request code is what we had given
    // earlier in startSubActivity
    switch (requestCode) {
      case REQUEST_CODE_CAMERA:
        setRequestedOrientation(
            ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); // pull it out of landscape mode
        break;

      case REQUEST_CODE_IMAGE:
        if (resultCode != RESULT_OK) {
          return;
        }
        Uri uri = data.getData();
        Bitmap b = null;
        try {
          b = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
        } catch (FileNotFoundException e) {
          break;
        } catch (IOException e) {
          break;
        }
        ByteArrayOutputStream byteArrayos = new ByteArrayOutputStream();
        try {
          b.compress(CompressFormat.JPEG, 75, byteArrayos);
          byteArrayos.flush();
        } catch (OutOfMemoryError e) {
          break;
        } catch (IOException e) {
          break;
        }
        filename = "android_pic_upload" + randomString() + ".jpg";
        ImageManager.writeImage(byteArrayos.toByteArray(), filename);
        UshahidiService.fileName = filename;
        selectedPhoto.setText(UshahidiService.fileName);
        break;

      case VIEW_MAP:
        if (resultCode != RESULT_OK) {
          return;
        }

        bundle = null;
        extras = data.getExtras();
        if (extras != null) bundle = extras.getBundle("locations");

        if (bundle != null && !bundle.isEmpty()) {
          incidentLocation.setText(bundle.getString("location"));

          AddIncident.latitude = bundle.getDouble("latitude");
          AddIncident.longitude = bundle.getDouble("longitude");
        }
        break;
    }
  }
 public static int selectedOption(Bundle data, String dataKey) {
   int selectedOption = -1;
   if (data != null && data.containsKey(dataKey)) {
     Bundle bundleSelectedOption = data.getBundle(dataKey);
     if (bundleSelectedOption != null) {
       selectedOption = bundleSelectedOption.getInt(DATA_SELECTED_OPTION, -1);
     }
   }
   return selectedOption;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
      Log.w(TAG, "Restored state");
      mOriginalSettings = savedInstanceState.getBundle(ORIGINAL_SETTINGS_NAME);
    } else {
      mOriginalSettings = new Bundle();
    }

    mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName());
    mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    Intent intent = getIntent();
    String action = intent.getAction();
    Log.d(TAG, "ByodHelperActivity.onCreate: " + action);

    // we are explicitly started by {@link DeviceAdminTestReceiver} after a successful provisioning.
    if (action.equals(ACTION_PROFILE_PROVISIONED)) {
      // Jump back to CTS verifier with result.
      Intent response = new Intent(ACTION_PROFILE_OWNER_STATUS);
      response.putExtra(EXTRA_PROVISIONED, isProfileOwner());
      startActivityInPrimary(response);
      // Queried by CtsVerifier in the primary side using startActivityForResult.
    } else if (action.equals(ACTION_QUERY_PROFILE_OWNER)) {
      Intent response = new Intent();
      response.putExtra(EXTRA_PROVISIONED, isProfileOwner());
      setResult(RESULT_OK, response);
      // Request to delete work profile.
    } else if (action.equals(ACTION_REMOVE_PROFILE_OWNER)) {
      if (isProfileOwner()) {
        mDevicePolicyManager.wipeData(0);
        showToast(R.string.provisioning_byod_profile_deleted);
      }
    } else if (action.equals(ACTION_INSTALL_APK)) {
      boolean allowNonMarket = intent.getBooleanExtra(EXTRA_ALLOW_NON_MARKET_APPS, false);
      boolean wasAllowed = getAllowNonMarket();

      // Update permission to install non-market apps
      setAllowNonMarket(allowNonMarket);
      mOriginalSettings.putBoolean(INSTALL_NON_MARKET_APPS, wasAllowed);

      // Request to install a non-market application- easiest way is to reinstall ourself
      final Intent installIntent =
          new Intent(Intent.ACTION_INSTALL_PACKAGE)
              .setData(Uri.parse("package:" + getPackageName()))
              .putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
              .putExtra(Intent.EXTRA_RETURN_RESULT, true);
      startActivityForResult(installIntent, REQUEST_INSTALL_PACKAGE);

      // Not yet ready to finish- wait until the result comes back
      return;
    }
    // This activity has no UI and is only used to respond to CtsVerifier in the primary side.
    finish();
  }
Exemplo n.º 29
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mMapView = (MapView) view.findViewById(R.id.map);
    mMapView.onCreate(savedInstanceState != null ? savedInstanceState.getBundle(STATE_MAP) : null);
    mMapView.getMapAsync(this);

    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    ((AppCompatActivity) getActivity()).setSupportActionBar(mToolbar);
    mWeatherModeBtn = (ImageButton) view.findViewById(R.id.feature_mode_weather_btn);
    mWeatherModeBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            setFeatureMode(FeatureMode.WEATHER);
          }
        });
    mTemperatureModeBtn = (ImageButton) view.findViewById(R.id.feature_mode_temperature_btn);
    mTemperatureModeBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            setFeatureMode(FeatureMode.TEMPERATURE);
          }
        });
    mLogoView = view.findViewById(R.id.logo);

    mPostButton = view.findViewById(R.id.post_button);
    mPostButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            showPostFragment(null);
          }
        });
    if (getHomeFragment() != null) {
      showHomeFragment();
    } else if (getPostFragment() != null) {
      showPostFragment(null);
    }

    if (savedInstanceState == null) {
      Bundle args = getArguments();
      if (args != null) {
        if (args.getBoolean(ARG_SHOW_HOME)) showHomeFragment();
        else if (args.getBoolean(ARG_SHOW_POST)) showPostFragment(args);
        else if (args.containsKey(ARG_LOCATION)) {
          mMapLocation = args.getParcelable(ARG_LOCATION);
        }
      }
      mWeatherModeBtn.setSelected(true);
    }
  }
Exemplo n.º 30
0
  public static Bundle getErrorDataFromResultIntent(Intent resultIntent) {
    if (!isErrorResult(resultIntent)) {
      return null;
    }

    Bundle bridgeArgs = getBridgeArgumentsFromIntent(resultIntent);
    if (bridgeArgs != null) {
      return bridgeArgs.getBundle(BRIDGE_ARG_ERROR_BUNDLE);
    }

    return resultIntent.getExtras();
  }