Java Code Examples for android.os.Build

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  15 
vote

public void onConfigurationChanged(Configuration newConfig){
  setHasEmbeddedTabs(getResources_getBoolean(mContext,R.bool.abs__action_bar_embed_tabs));
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
    mActionView.onConfigurationChanged(newConfig);
    if (mContextView != null) {
      mContextView.onConfigurationChanged(newConfig);
    }
  }
}
 

Example 2

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/app/.

Source file: SherlockFragmentActivity.java

  15 
vote

@Override public boolean onCreatePanelMenu(int featureId,Menu menu){
  if (DEBUG)   Log.d(TAG,"[onCreatePanelMenu] featureId: " + featureId + ", menu: "+ menu);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    boolean result=onCreateOptionsMenu(menu);
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] dispatching to native with mule");
    mOverrideNativeCreate=result;
    boolean fragResult=super.onCreatePanelMenu(featureId,new MenuMule(menu));
    mOverrideNativeCreate=null;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      result|=menu.hasVisibleItems();
    }
 else {
      result|=fragResult;
    }
    return result;
  }
  return false;
}
 

Example 3

From project AChartEngine, under directory /achartengine/src/org/achartengine/.

Source file: GraphicalView.java

  15 
vote

/** 
 * Creates a new graphical view.
 * @param context the context
 * @param chart the chart to be drawn
 */
public void setup(Context context){
  AbstractChart chart=buildChart();
  mChart=chart;
  mHandler=new Handler();
  if (mChart instanceof XYChart) {
    mRenderer=((XYChart)mChart).getRenderer();
  }
 else {
    mRenderer=((RoundChart)mChart).getRenderer();
  }
  if (mRenderer.isZoomButtonsVisible()) {
    zoomInImage=BitmapFactory.decodeStream(GraphicalView.class.getResourceAsStream("image/zoom_in.png"));
    zoomOutImage=BitmapFactory.decodeStream(GraphicalView.class.getResourceAsStream("image/zoom_out.png"));
    fitZoomImage=BitmapFactory.decodeStream(GraphicalView.class.getResourceAsStream("image/zoom-1.png"));
  }
  if (mRenderer instanceof XYMultipleSeriesRenderer && ((XYMultipleSeriesRenderer)mRenderer).getMarginsColor() == XYMultipleSeriesRenderer.NO_COLOR) {
    ((XYMultipleSeriesRenderer)mRenderer).setMarginsColor(mPaint.getColor());
  }
  if (mRenderer.isZoomEnabled() && mRenderer.isZoomButtonsVisible() || mRenderer.isExternalZoomEnabled()) {
    mZoomIn=new Zoom(mChart,true,mRenderer.getZoomRate());
    mZoomOut=new Zoom(mChart,false,mRenderer.getZoomRate());
    mFitZoom=new FitZoom(mChart);
  }
  int version=7;
  try {
    version=Integer.valueOf(Build.VERSION.SDK);
  }
 catch (  Exception e) {
  }
  if (version < 7) {
    mTouchHandler=new TouchHandlerOld(this,mChart);
  }
 else {
    mTouchHandler=new TouchHandler(this,mChart);
  }
}
 

Example 4

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: ActionBarHelper.java

  15 
vote

/** 
 * Factory method for creating  {@link ActionBarHelper} objects for agiven activity. Depending on which device the app is running, either a basic helper or Honeycomb-specific helper will be returned.
 */
public static ActionBarHelper createInstance(Activity activity){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    return new ActionBarHelperICS(activity);
  }
 else   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    return new ActionBarHelperHoneycomb(activity);
  }
 else {
    return new ActionBarHelperBase(activity);
  }
}
 

Example 5

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  15 
vote

public void onConfigurationChanged(Configuration newConfig){
  setHasEmbeddedTabs(getResources_getBoolean(mContext,R.bool.abs__action_bar_embed_tabs));
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
    mActionView.onConfigurationChanged(newConfig);
    if (mContextView != null) {
      mContextView.onConfigurationChanged(newConfig);
    }
  }
}
 

Example 6

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: BlobViewFragment.java

  15 
vote

public void displayBlob(){
  WebView webView=getWebView();
  WebSettings settings=webView.getSettings();
  settings.setUseWideViewPort(true);
  settings.setJavaScriptEnabled(true);
  settings.setBuiltInZoomControls(true);
  if (Build.VERSION.SDK_INT >= HONEYCOMB) {
    settings.setDisplayZoomControls(false);
  }
  webView.loadDataWithBaseURL("file:///android_asset",blobHTML,"text/html","UTF-8",null);
}
 

Example 7

From project Airports, under directory /src/com/nadmm/airports/.

Source file: ActivityBase.java

  15 
vote

@TargetApi(11) @Override public boolean onCreateOptionsMenu(Menu menu){
  MenuInflater inflater=getSupportMenuInflater();
  inflater.inflate(R.menu.mainmenu,menu);
  mRefreshItem=menu.findItem(R.id.menu_refresh);
  mRefreshDrawable=mRefreshItem.getIcon();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    SearchManager searchManager=(SearchManager)getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView=new SearchView(getSupportActionBar().getThemedContext());
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    menu.findItem(R.id.menu_search).setActionView(searchView);
  }
  return super.onCreateOptionsMenu(menu);
}
 

Example 8

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  15 
vote

public void onConfigurationChanged(Configuration newConfig){
  setHasEmbeddedTabs(getResources_getBoolean(mContext,R.bool.abs__action_bar_embed_tabs));
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
    mActionView.onConfigurationChanged(newConfig);
    if (mContextView != null) {
      mContextView.onConfigurationChanged(newConfig);
    }
  }
}
 

Example 9

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/.

Source file: SettingsActivity.java

  15 
vote

private void showEditDialog(){
  FragmentManager fm=getSupportFragmentManager();
  SignupDialog signupDialog=new SignupDialog();
  signupDialog.setEmail(emailField.getText().toString());
  signupDialog.setPassword(passwordField.getText().toString());
  if (Build.VERSION.SDK_INT <= 10) {
    signupDialog.setStyle(DialogFragment.STYLE_NORMAL,R.style.Theme_HoloEverywhereDark_Sherlock);
  }
  signupDialog.show(fm,"fragment_sign_up");
}
 

Example 10

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  15 
vote

public void onConfigurationChanged(Configuration newConfig){
  setHasEmbeddedTabs(getResources_getBoolean(mContext,R.bool.abs__action_bar_embed_tabs));
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
    mActionView.onConfigurationChanged(newConfig);
    if (mContextView != null) {
      mContextView.onConfigurationChanged(newConfig);
    }
  }
}
 

Example 11

From project Android, under directory /AndroidNolesCore/src/activities/.

Source file: AbstractMainActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  final boolean SUPPORTS_GINGERBREAD=Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
  if (BuildConfig.DEBUG && SUPPORTS_GINGERBREAD) {
    StrictMode.enableDefaults();
  }
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  final AsyncTask<Void,Void,Void> enableCache=new AsyncTask<Void,Void,Void>(){
    @Override protected Void doInBackground(    Void... urls){
      enableHttpResponseCache();
      return null;
    }
  }
;
  enableCache.execute();
  mViewPager=(ViewPager)findViewById(R.id.pager);
}
 

Example 12

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: PhotoSyncActivity.java

  15 
vote

/** 
 * Returns  {@link View.OnClickListener} for "Add" button. When the button is clicked application determines whether it runs onthe emulator or the actual device and based on that knowledge takes a photo from its resources or using phones camera.
 */
private View.OnClickListener getOnAddClickListener(){
  return new View.OnClickListener(){
    @Override public void onClick(    final View v){
      CharSequence[] items={"Camera","Photo gallery","Random image"};
      final boolean isEmulator="google_sdk".equals(Build.PRODUCT) || "sdk".equals(Build.PRODUCT);
      if (isEmulator) {
        items=new CharSequence[]{"Photo gallery","Random image"};
      }
      AlertDialog.Builder builder=new AlertDialog.Builder(v.getContext());
      builder.setTitle("Choose source:");
      builder.setItems(items,new DialogInterface.OnClickListener(){
        @Override public void onClick(        final DialogInterface dialog,        final int item){
          if (isEmulator) {
            if (item == 0) {
              getImageFromGallery();
            }
 else {
              getRandomImage();
            }
          }
 else {
            if (item == 0) {
              getImageFromCamera();
            }
 else             if (item == 1) {
              getImageFromGallery();
            }
 else {
              getRandomImage();
            }
          }
        }
      }
);
      AlertDialog alert=builder.create();
      alert.show();
    }
  }
;
}
 

Example 13

From project android-api_1, under directory /android-lib/src/com/catchnotes/api/.

Source file: CatchAPI.java

  15 
vote

/** 
 * Constructor.
 * @param appName The name of your application.
 * @param context Android context.
 */
public CatchAPI(String appName,Context context){
  source=appName;
  mContext=context;
  String version="x.xx";
  try {
    PackageInfo info=mContext.getPackageManager().getPackageInfo(mContext.getPackageName(),0);
    version=info.versionName;
  }
 catch (  Exception e) {
  }
  StringBuilder locale=new StringBuilder(5);
  String language=Locale.getDefault().getLanguage();
  if (language != null) {
    locale.append(language);
    String country=Locale.getDefault().getCountry();
    if (country != null) {
      locale.append('-');
      locale.append(country);
    }
  }
  userAgent=appName + '/' + version+ " (Android; "+ Build.VERSION.RELEASE+ "; "+ Build.BRAND+ "; "+ Build.MODEL+ "; "+ locale.toString()+ ')';
  try {
    if (Integer.parseInt(Build.VERSION.SDK) >= Build.VERSION_CODES.ECLAIR_0_1) {
      timestamper=new Time();
    }
  }
 catch (  Exception e) {
  }
}
 

Example 14

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: MapView.java

  15 
vote

/** 
 * Detects if the code is currently executed on the emulator from the Android SDK. This method can be used for code branches to work around known bugs in the Android emulator.
 * @return true if the Android emulator has been detected, false otherwise.
 */
private static boolean isAndroidEmulator(){
  for (  String name : EMULATOR_NAMES) {
    if (Build.PRODUCT.equals(name)) {
      return true;
    }
  }
  return false;
}
 

Example 15

From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.

Source file: GaActivity.java

  15 
vote

public void startTracker(){
  if (!"google_sdk".equals(Build.PRODUCT) && !"sdk".equals(Build.PRODUCT)) {
    tracker=GoogleAnalyticsTracker.getInstance();
    tracker.start(Config.WEB_PROPERTY_ID,20,this);
  }
}
 

Example 16

From project android-tether, under directory /src/og/android/tether/system/.

Source file: BluetoothService.java

  15 
vote

public static BluetoothService getInstance(){
  if (bluetoothService == null) {
    String className;
    int sdkVersion=Integer.parseInt(Build.VERSION.SDK);
    if (sdkVersion < Build.VERSION_CODES.ECLAIR) {
      className="og.android.tether.system.BluetoothService_cupcake";
    }
 else {
      className="og.android.tether.system.BluetoothService_eclair";
    }
    try {
      Class<? extends BluetoothService> clazz=Class.forName(className).asSubclass(BluetoothService.class);
      bluetoothService=clazz.newInstance();
    }
 catch (    Exception e) {
      throw new IllegalStateException(e);
    }
  }
  return bluetoothService;
}
 

Example 17

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/deprecated/voice/.

Source file: VoiceInput.java

  15 
vote

private static Intent makeIntent(){
  Intent intent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  if (Build.VERSION.RELEASE.equals("1.5")) {
    intent=intent.setClassName("com.google.android.voiceservice","com.google.android.voiceservice.IMERecognitionService");
  }
 else {
    intent=intent.setClassName("com.google.android.voicesearch","com.google.android.voicesearch.RecognitionService");
  }
  return intent;
}
 

Example 18

From project android-voip-service, under directory /src/main/java/org/linphone/core/.

Source file: Hacks.java

  15 
vote

public static void dumpDeviceInformation(){
  StringBuilder sb=new StringBuilder(" ==== Phone information dump ====\n");
  sb.append("DEVICE=").append(Build.DEVICE).append("\n");
  sb.append("MODEL=").append(Build.MODEL).append("\n");
  sb.append("SDK=").append(Build.VERSION.SDK);
  Log.i(sb.toString());
}
 

Example 19

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/activity/.

Source file: HomeActivity.java

  15 
vote

@Override @TargetApi(9) public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.home);
  if (Build.VERSION.SDK_INT >= 9) {
    final StrictMode.ThreadPolicy policy=new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
  }
  final Display display=getWindowManager().getDefaultDisplay();
  ThumbSize.setScreenSize(display.getWidth(),display.getHeight());
  final Button versionButton=(Button)findViewById(R.id.home_version_button);
  final GridView menuGrid=(GridView)findViewById(R.id.HomeItemGridView);
  mHomeController=new HomeController(this,new Handler(),menuGrid);
  mHomeController.setupVersionHandler(new Handler(),versionButton,menuGrid);
  mEventClientManager=ManagerFactory.getEventClientManager(mHomeController);
  mConfigurationManager=ConfigurationManager.getInstance(this);
  versionButton.setText("Connecting...");
  versionButton.setOnClickListener(mHomeController.getOnHostChangeListener());
  ((Button)findViewById(R.id.home_about_button)).setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      startActivity(new Intent(HomeActivity.this,AboutActivity.class));
    }
  }
);
}
 

Example 20

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/remotesandbox/ui/base/.

Source file: ActionBarHelper.java

  15 
vote

/** 
 * Factory method for creating  {@link ActionBarHelper} objects for agiven activity. Depending on which device the app is running, either a basic helper or Honeycomb-specific helper will be returned.
 */
public static ActionBarHelper createInstance(Activity activity){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    return new ActionBarHelperICS(activity);
  }
 else   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    return new ActionBarHelperHoneycomb(activity);
  }
 else {
    return new ActionBarHelperBase(activity);
  }
}
 

Example 21

From project AndroidCommon, under directory /src/com/asksven/android/system/.

Source file: AndroidVersion.java

  15 
vote

public static boolean isFroyo(){
  boolean bRet=false;
  if (Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO) {
    bRet=true;
  }
  return bRet;
}
 

Example 22

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: HomeActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  if (C.DEVELOPER_MODE) {
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDeathOnNetwork().build());
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
  }
  super.onCreate(savedInstanceState);
  setContentView(R.layout.home);
  gvPreview=(GridView)findViewById(R.id.home_grid);
  emptyGrid=getLayoutInflater().inflate(R.layout.home_grid_empty,null);
  emptyGrid.findViewById(R.id.home_grid_empty).setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      showDialog(C.DIALOG_NEW_MAP);
    }
  }
);
  @SuppressWarnings("deprecation") int emptyGrid_layout_size=LayoutParams.FILL_PARENT;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
    emptyGrid_layout_size=LayoutParams.MATCH_PARENT;
  }
  addContentView(emptyGrid,new LayoutParams(emptyGrid_layout_size,emptyGrid_layout_size));
  gvPreview.setEmptyView(emptyGrid);
  getSupportLoaderManager().initLoader(0,null,this);
  String[] cols=new String[]{"_id","_name","_json_data","_last_update"};
  adapter=new MySimpleCursorAdapter(getApplicationContext(),R.layout.home_grid_item,null,cols,null,0);
  gvPreview.setAdapter(adapter);
  gvPreview.setOnItemClickListener(this);
  registerForContextMenu(gvPreview);
  progressDialog=ProgressDialog.show(HomeActivity.this,null,getString(R.string.home_dlg_loading_maps),true);
}
 

Example 23

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/app/.

Source file: SherlockFragmentActivity.java

  15 
vote

@Override public boolean onCreatePanelMenu(int featureId,Menu menu){
  if (DEBUG)   Log.d(TAG,"[onCreatePanelMenu] featureId: " + featureId + ", menu: "+ menu);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    boolean result=onCreateOptionsMenu(menu);
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] dispatching to native with mule");
    mOverrideNativeCreate=result;
    boolean fragResult=super.onCreatePanelMenu(featureId,new MenuMule(menu));
    mOverrideNativeCreate=null;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      result|=menu.hasVisibleItems();
    }
 else {
      result|=fragResult;
    }
    return result;
  }
  return false;
}
 

Example 24

From project Android_1, under directory /Fragments/simple/src/novoda/demo/fragments/list/activities/.

Source file: Details.java

  15 
vote

@Override public boolean onOptionsItemSelected(android.view.MenuItem item){
switch (item.getItemId()) {
case android.R.id.home:
    Intent intent=new Intent(this,List.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
OverridePendingTransition.invoke(this);
}
}
return super.onOptionsItemSelected(item);
}
 

Example 25

From project android_5, under directory /src/aarddict/android/.

Source file: DeviceInfo.java

  15 
vote

private static String getBuildField(String fieldName){
  try {
    return (String)Build.class.getField(fieldName).get(null);
  }
 catch (  Exception e) {
    Log.d("aarddict","Exception while trying to check Build." + fieldName);
    return "";
  }
}
 

Example 26

From project android_7, under directory /src/org/immopoly/android/widget/.

Source file: ViewPager.java

  15 
vote

/** 
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event){
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
      handled=arrowScroll(FOCUS_LEFT);
    break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
  handled=arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
if (KeyEventCompat.hasNoModifiers(event)) {
  handled=arrowScroll(FOCUS_FORWARD);
}
 else if (KeyEventCompat.hasModifiers(event,KeyEvent.META_SHIFT_ON)) {
  handled=arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
 

Example 27

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: DeviceInfoSettings.java

  15 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  addPreferencesFromResource(R.xml.device_info_settings);
  String currentIme=Settings.Secure.getString(getContentResolver(),Settings.Secure.DEFAULT_INPUT_METHOD);
  ComponentName component=ComponentName.unflattenFromString(currentIme);
  Intent imeIntent=new Intent(component.getPackageName() + ".tutorial");
  PackageManager pm=getPackageManager();
  List<ResolveInfo> tutorials=pm.queryIntentActivities(imeIntent,0);
  if (tutorials == null || tutorials.isEmpty()) {
    getPreferenceScreen().removePreference(findPreference("system_tutorial"));
  }
  setStringSummary("firmware_version",Build.VERSION.RELEASE);
  findPreference("firmware_version").setEnabled(true);
  setValueSummary("baseband_version","gsm.version.baseband");
  setStringSummary("device_model",Build.MODEL);
  setStringSummary("build_number",Build.DISPLAY);
  findPreference("kernel_version").setSummary(getFormattedKernelVersion());
  removePreferenceIfPropertyMissing(getPreferenceScreen(),"safetylegal",PROPERTY_URL_SAFETYLEGAL);
  PreferenceGroup parentPreference=(PreferenceGroup)findPreference(KEY_CONTAINER);
  Utils.updatePreferenceToSpecificActivityOrRemove(this,parentPreference,KEY_TERMS,Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
  Utils.updatePreferenceToSpecificActivityOrRemove(this,parentPreference,KEY_LICENSE,Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
  Utils.updatePreferenceToSpecificActivityOrRemove(this,parentPreference,KEY_COPYRIGHT,Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
  Utils.updatePreferenceToSpecificActivityOrRemove(this,parentPreference,KEY_TEAM,Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
  parentPreference=getPreferenceScreen();
  Utils.updatePreferenceToSpecificActivityOrRemove(this,parentPreference,KEY_SYSTEM_UPDATE_SETTINGS,Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
  Utils.updatePreferenceToSpecificActivityOrRemove(this,parentPreference,KEY_CONTRIBUTORS,Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
  boolean mUpdateSettingAvailable=getResources().getBoolean(R.bool.config_additional_system_update_setting_enable);
  if (mUpdateSettingAvailable == false) {
    getPreferenceScreen().removePreference(findPreference(KEY_UPDATE_SETTING));
  }
}
 

Example 28

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/.

Source file: EasSyncService.java

  15 
vote

private boolean sendSettings() throws IOException {
  Serializer s=new Serializer();
  s.start(Tags.SETTINGS_SETTINGS);
  s.start(Tags.SETTINGS_DEVICE_INFORMATION).start(Tags.SETTINGS_SET);
  s.data(Tags.SETTINGS_MODEL,Build.MODEL);
  s.data(Tags.SETTINGS_OS,"Android " + Build.VERSION.RELEASE);
  s.data(Tags.SETTINGS_USER_AGENT,USER_AGENT);
  s.end().end().end().done();
  EasResponse resp=sendHttpClientPost("Settings",s.toByteArray());
  try {
    int code=resp.getStatus();
    if (code == HttpStatus.SC_OK) {
      InputStream is=resp.getInputStream();
      SettingsParser sp=new SettingsParser(is,this);
      return sp.parse();
    }
  }
  finally {
    resp.close();
  }
  return false;
}
 

Example 29

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: CameraHolder.java

  15 
vote

/** 
 * Tries to open the hardware camera. If the camera is being used or unavailable then return  {@code null}.
 */
public synchronized android.hardware.Camera tryOpen(){
  try {
    return mUsers == 0 ? open() : null;
  }
 catch (  CameraHardwareException e) {
    if ("eng".equals(Build.TYPE)) {
      throw new RuntimeException(e);
    }
    return null;
  }
}
 

Example 30

From project android_packages_apps_Gallery2, under directory /gallerycommon/src/com/android/gallery3d/common/.

Source file: HttpClientFactory.java

  15 
vote

private static String getUserAgent(Context context){
  if (sUserAgent == null) {
    PackageInfo pi;
    try {
      pi=context.getPackageManager().getPackageInfo(context.getPackageName(),0);
    }
 catch (    NameNotFoundException e) {
      throw new IllegalStateException("getPackageInfo failed");
    }
    sUserAgent=String.format("%s/%s; %s/%s/%s/%s; %s/%s/%s",pi.packageName,pi.versionName,Build.BRAND,Build.DEVICE,Build.MODEL,Build.ID,Build.VERSION.SDK,Build.VERSION.RELEASE,Build.VERSION.INCREMENTAL);
  }
  return sUserAgent;
}
 

Example 31

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/preferences/.

Source file: PreferencesActivityHC.java

  15 
vote

@Override public void setListAdapter(ListAdapter adapter){
  if (mHeaders == null) {
    mHeaders=new ArrayList<Header>();
    for (int i=0; i < adapter.getCount(); i++) {
      mHeaders.add((Header)adapter.getItem(i));
    }
  }
  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
    super.setListAdapter(new HeaderAdapter(this,mHeaders));
  }
 else {
    super.setListAdapter(adapter);
  }
}
 

Example 32

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/.

Source file: MyTagList.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.my_tag_activity);
  if (savedInstanceState != null) {
    mTagIdInEdit=savedInstanceState.getLong(BUNDLE_KEY_TAG_ID_IN_EDIT,-1);
  }
  mEnabled=(CheckBox)findViewById(R.id.toggle_enabled_checkbox);
  mEnabled.setChecked(false);
  findViewById(R.id.toggle_enabled_target).setOnClickListener(this);
  mActiveTagDetails=findViewById(R.id.active_tag_details);
  mSelectActiveTagAnchor=findViewById(R.id.choose_my_tag);
  findViewById(R.id.active_tag).setOnClickListener(this);
  updateActiveTagView(null);
  mActiveTagId=getPreferences(Context.MODE_PRIVATE).getLong(PREF_KEY_ACTIVE_TAG,-1);
  mAdapter=new TagAdapter(this);
  mList=(ListView)findViewById(android.R.id.list);
  mList.setAdapter(mAdapter);
  mList.setOnItemClickListener(this);
  findViewById(R.id.add_tag).setOnClickListener(this);
  mList.setEmptyView(null);
  new TagLoaderTask().execute((Void[])null);
  if (!Build.TYPE.equalsIgnoreCase("user")) {
    mWriteSupport=true;
  }
  registerForContextMenu(mList);
  if (getIntent().hasExtra(EditTagActivity.EXTRA_RESULT_MSG)) {
    NdefMessage msg=(NdefMessage)Preconditions.checkNotNull(getIntent().getParcelableExtra(EditTagActivity.EXTRA_RESULT_MSG));
    saveNewMessage(msg);
  }
}
 

Example 33

From project android_packages_apps_VoiceDialer_2, under directory /src/com/android/voicedialer/.

Source file: RecognizerLogger.java

  15 
vote

/** 
 * Constructor
 * @param dataDir directory to contain the log files.
 */
public RecognizerLogger(Context context) throws IOException {
  if (false)   Log.d(TAG,"RecognizerLogger");
  File dir=context.getDir(LOGDIR,0);
  mDatedPath=dir.toString() + File.separator + "log_"+ DateFormat.format("yyyy_MM_dd_kk_mm_ss",System.currentTimeMillis());
  deleteOldest(".wav");
  deleteOldest(".log");
  mWriter=new BufferedWriter(new FileWriter(mDatedPath + ".log"),8192);
  mWriter.write(Build.FINGERPRINT);
  mWriter.newLine();
}
 

Example 34

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/deprecated/voice/.

Source file: VoiceInput.java

  15 
vote

private static Intent makeIntent(){
  Intent intent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  if (Build.VERSION.RELEASE.equals("1.5")) {
    intent=intent.setClassName("com.google.android.voiceservice","com.google.android.voiceservice.IMERecognitionService");
  }
 else {
    intent=intent.setClassName("com.google.android.voicesearch","com.google.android.voicesearch.RecognitionService");
  }
  return intent;
}
 

Example 35

From project androlog, under directory /androlog/src/main/java/de/akquinet/android/androlog/reporter/.

Source file: Report.java

  15 
vote

/** 
 * Adds the device data to the report.
 * @param report the report
 * @throws JSONException if the device data cannot be added
 */
private void addDeviceData(JSONObject report) throws JSONException {
  JSONObject device=new JSONObject();
  device.put("device",Build.DEVICE);
  device.put("brand",Build.BRAND);
  Object windowService=context.getSystemService(Context.WINDOW_SERVICE);
  if (windowService instanceof WindowManager) {
    Display display=((WindowManager)windowService).getDefaultDisplay();
    device.put("resolution",display.getWidth() + "x" + display.getHeight());
    device.put("orientation",display.getOrientation());
  }
  device.put("display",Build.DISPLAY);
  device.put("manufacturer",Build.MANUFACTURER);
  device.put("model",Build.MODEL);
  device.put("product",Build.PRODUCT);
  device.put("build.type",Build.TYPE);
  device.put("android.version",Build.VERSION.SDK_INT);
  report.put("device",device);
}
 

Example 36

From project Anki-Android, under directory /src/com/tomgibara/android/veecheck/.

Source file: VeecheckVersion.java

  15 
vote

/** 
 * Constructs a version that draws all of its properties from the supplied context.
 * @param context the context from which version properties will be drawn
 */
VeecheckVersion(Context context){
  try {
    PackageManager manager=context.getPackageManager();
    PackageInfo info=manager.getPackageInfo(context.getPackageName(),0);
    packageName=info.packageName;
    versionCode=Integer.toString(info.versionCode);
    versionName=info.versionName;
  }
 catch (  NameNotFoundException e) {
    Log.w(LOG_TAG,"Unable to obtain package info: ",e);
  }
  buildBrand=Build.BRAND;
  buildId=Build.ID;
  buildModel=Build.MODEL;
}
 

Example 37

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/voice/.

Source file: ActivityHelper.java

  15 
vote

@TargetApi(11) private Dialog createResultDialog(final String[] recognitionResults){
  AlertDialog.Builder builder;
  if (Build.VERSION.SDK_INT < 11) {
    builder=new AlertDialog.Builder(this);
  }
 else {
    builder=new AlertDialog.Builder(this,0x1030071);
  }
  builder.setItems(recognitionResults,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      notifyResult(recognitionResults[which]);
    }
  }
);
  builder.setCancelable(true);
  builder.setOnCancelListener(new DialogInterface.OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      notifyResult(null);
    }
  }
);
  builder.setNeutralButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      notifyResult(null);
    }
  }
);
  return builder.create();
}
 

Example 38

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/util/.

Source file: AnalyticsUtils.java

  15 
vote

private AnalyticsUtils(Context context){
  if (context == null) {
    return;
  }
  mApplicationContext=context.getApplicationContext();
  mTracker=GoogleAnalyticsTracker.getInstance();
  mTracker.start(UACODE,300,mApplicationContext);
  Log.d(TAG,"Initializing Analytics");
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mApplicationContext);
  final boolean firstRun=prefs.getBoolean(FIRST_RUN_KEY,true);
  if (firstRun) {
    Log.d(TAG,"Analytics firstRun");
    String apiLevel=Integer.toString(Build.VERSION.SDK_INT);
    String model=Build.MODEL;
    mTracker.setCustomVar(1,"apiLevel",apiLevel,VISITOR_SCOPE);
    mTracker.setCustomVar(2,"model",model,VISITOR_SCOPE);
    prefs.edit().putBoolean(FIRST_RUN_KEY,false).commit();
  }
}
 

Example 39

From project badgescanner, under directory /src/net/tjohns/badgescanner/.

Source file: ScanActivity.java

  15 
vote

public void flipToBack(View view){
  if (Build.VERSION.SDK_INT > 11) {
    ObjectAnimator anim=ObjectAnimator.ofFloat(findViewById(R.id.card_front),ROTATION_AXIS_PROP,0,90).setDuration(ROTATION_HALF_DURATION);
    anim.addListener(new AnimatorListenerAdapter(){
      @Override public void onAnimationEnd(      Animator animation){
        findViewById(R.id.card_front).setVisibility(View.GONE);
        findViewById(R.id.card_back).setVisibility(View.VISIBLE);
        ObjectAnimator.ofFloat(findViewById(R.id.card_back),ROTATION_AXIS_PROP,-90,0).start();
      }
    }
);
    anim.start();
  }
 else {
    findViewById(R.id.card_front).setVisibility(View.GONE);
    findViewById(R.id.card_back).setVisibility(View.VISIBLE);
  }
}
 

Example 40

From project Barcamp-Bangalore-Android-App, under directory /slidingmenu/library/src/com/slidingmenu/lib/.

Source file: CustomViewAbove.java

  15 
vote

/** 
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event){
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
      handled=arrowScroll(FOCUS_LEFT);
    break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
  handled=arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
if (KeyEventCompat.hasNoModifiers(event)) {
  handled=arrowScroll(FOCUS_FORWARD);
}
 else if (KeyEventCompat.hasModifiers(event,KeyEvent.META_SHIFT_ON)) {
  handled=arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
 

Example 41

From project BART, under directory /src/pro/dbro/bart/.

Source file: TheActivity.java

  15 
vote

@Override public boolean onCreateOptionsMenu(Menu menu){
  if (Build.VERSION.SDK_INT < 11) {
    MenuItem mi=menu.add(0,0,0,"About");
    mi.setIcon(R.drawable.about);
  }
 else {
    MenuInflater inflater=getMenuInflater();
    inflater.inflate(R.layout.actionitem,menu);
  }
  return super.onCreateOptionsMenu(menu);
}
 

Example 42

From project BazaarUtils, under directory /src/com/congenialmobile/adad/.

Source file: AdsManager.java

  15 
vote

/** 
 * Prepare the data that should be sent to the server. The returned string
 * @return The string ready to be appended to the URL for passing data by GET method.
 */
private String prepareData(){
  TelephonyManager tm=(TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
  String s=null;
  s="deviceid=" + mUUID;
  s+="&androidid=" + Secure.getString(mContext.getContentResolver(),Secure.ANDROID_ID);
  s+="&token=" + mToken;
  s+="&brand=" + URLEncoder.encode(Build.BRAND);
  s+="&model=" + URLEncoder.encode(Build.MODEL);
  s+="&width=" + mWidth;
  s+="&height=" + mHeight;
  s+="&density=" + mDensity;
  s+="&car=" + URLEncoder.encode(tm.getNetworkOperator());
  s+="&data=";
  if (tm.getDataState() == TelephonyManager.DATA_CONNECTED) {
    s+="1";
  }
 else {
    s+="0";
  }
  s+="&lang=" + Locale.getDefault().getLanguage();
  return s;
}
 

Example 43

From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/util/.

Source file: ViewServer.java

  15 
vote

/** 
 * Returns a unique instance of the ViewServer. This method should only be called from the main thread of your application. The server will have the same lifetime as your process. If your application does not have the <code>android:debuggable</code> flag set in its manifest, the server returned by this method will be a dummy object that does not do anything. This allows you to use the same code in debug and release versions of your application.
 * @param context A Context used to check whether the application is debuggable, this can be the application context
 */
public static ViewServer get(Context context){
  ApplicationInfo info=context.getApplicationInfo();
  if (BUILD_TYPE_USER.equals(Build.TYPE) && (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
    if (sServer == null) {
      sServer=new ViewServer(ViewServer.VIEW_SERVER_DEFAULT_PORT);
    }
    if (!sServer.isRunning()) {
      try {
        sServer.start();
      }
 catch (      IOException e) {
        Log.d("LocalViewServer","Error:",e);
      }
    }
  }
 else {
    sServer=new NoopViewServer();
  }
  return sServer;
}
 

Example 44

From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/beintoosdkui/.

Source file: BeintooSignupBrowser.java

  15 
vote

private boolean isGinger(){
  try {
    if ((Build.VERSION.RELEASE).contains("2.3")) {
      return true;
    }
  }
 catch (  Exception e) {
  }
  return false;
}
 

Example 45

From project BF3-Battlelog, under directory /src/com/coveragemapper/android/Map/.

Source file: ExternalCacheDirectory.java

  15 
vote

public static ExternalCacheDirectory getInstance(final Context context){
  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ECLAIR_MR1) {
    return new ExternalCacheDirectory8(context);
  }
  return new ExternalCacheDirectory1(context);
}
 

Example 46

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/controls/.

Source file: ReaderWebView.java

  15 
vote

public boolean onSingleTapConfirmed(MotionEvent event){
  int x=(int)event.getX();
  int y=(int)event.getY();
  if (isStudyMode) {
    if (Build.VERSION.SDK_INT < 8) {
      y+=getScrollY();
    }
    float density=getContext().getResources().getDisplayMetrics().density;
    x=(int)(x / density);
    y=(int)(y / density);
    loadUrl("javascript:handleClick(" + x + ", "+ y+ ");");
    notifyListeners(ChangeCode.onChangeSelection);
  }
 else {
    int width=this.getWidth();
    int height=this.getHeight();
    if (((float)y / height) <= 0.33) {
      notifyListeners(ChangeCode.onUpNavigation);
    }
 else     if (((float)y / height) > 0.67) {
      notifyListeners(ChangeCode.onDownNavigation);
    }
 else     if (((float)x / width) <= 0.33) {
      notifyListeners(ChangeCode.onLeftNavigation);
    }
 else     if (((float)x / width) > 0.67) {
      notifyListeners(ChangeCode.onRightNavigation);
    }
  }
  return false;
}
 

Example 47

From project Birthdays, under directory /src/com/rexmenpara/birthdays/util/.

Source file: CalendarHelper.java

  15 
vote

public CalendarHelper(){
  if (Build.VERSION.SDK_INT >= 8)   contentProvider="com.android.calendar";
 else   contentProvider="calendar";
  remindersUri=Uri.parse(String.format("content://%s/reminders",contentProvider));
  eventsUri=Uri.parse(String.format("content://%s/events",contentProvider));
  calendars=Uri.parse(String.format("content://%s/calendars",contentProvider));
  this.context=ContextManager.getContext();
  this.timezone=getCurrentTimeZoneString();
}
 

Example 48

From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.

Source file: WalletActivity.java

  15 
vote

@Override public boolean onCreateOptionsMenu(final Menu menu){
  super.onCreateOptionsMenu(menu);
  getSupportMenuInflater().inflate(R.menu.wallet_options,menu);
  menu.findItem(R.id.wallet_options_donate).setVisible(!Constants.TEST);
  menu.findItem(R.id.wallet_options_import_keys).setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO);
  menu.findItem(R.id.wallet_options_export_keys).setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO);
  return true;
}
 

Example 49

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: BooksOnBookshelf.java

  15 
vote

/** 
 * Set the listview background based on user preferences
 */
private void initBackground(){
  ListView lv=getListView();
  View root=findViewById(R.id.root);
  View header=findViewById(R.id.header);
  if (root == null)   throw new RuntimeException("Sanity Check Fail: Root view not found; isFinishing() = " + isFinishing());
  if (header == null)   throw new RuntimeException("Sanity Check Fail: Header view not found; isFinishing() = " + isFinishing());
  if (getResources() == null)   throw new RuntimeException("Sanity Check Fail: getResources() returned null; isFinishing() = " + isFinishing());
  if (BooklistPreferencesActivity.isBackgroundFlat() || BookCatalogueApp.isBackgroundImageDisabled()) {
    lv.setBackgroundColor(0xFF202020);
    Utils.setCacheColorHintSafely(lv,0xFF202020);
    if (BookCatalogueApp.isBackgroundImageDisabled()) {
      root.setBackgroundColor(0xFF202020);
      header.setBackgroundColor(0xFF202020);
    }
 else {
      root.setBackgroundDrawable(Utils.cleanupTiledBackground(getResources().getDrawable(R.drawable.bc_background_gradient)));
      header.setBackgroundDrawable(Utils.cleanupTiledBackground(getResources().getDrawable(R.drawable.bc_vertical_gradient)));
    }
  }
 else {
    Utils.setCacheColorHintSafely(lv,0x00000000);
    if (Build.VERSION.SDK_INT >= 11) {
      lv.setBackgroundDrawable(Utils.cleanupTiledBackground(getResources().getDrawable(R.drawable.bc_background_gradient_dim)));
    }
 else {
      lv.setBackgroundColor(0x00000000);
    }
    root.setBackgroundDrawable(Utils.cleanupTiledBackground(getResources().getDrawable(R.drawable.bc_background_gradient_dim)));
    header.setBackgroundColor(0x00000000);
  }
  root.invalidate();
}
 

Example 50

From project Cafe, under directory /testservice/src/com/baidu/cafe/remote/.

Source file: SystemLib.java

  15 
vote

/** 
 * @return height of status bar
 */
public int getStatusBarHeight(){
  int statusBarHeight=0;
  try {
    Log.print("Build.VERSION.SDK_INT: " + Build.VERSION.SDK_INT);
    if (Build.VERSION.SDK_INT >= 14) {
    }
 else {
      statusBarHeight=mContext.getResources().getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
    }
  }
 catch (  Exception e) {
  }
  return statusBarHeight;
}
 

Example 51

From project callmeter, under directory /src/de/ub0r/android/callmeter/data/.

Source file: Device.java

  15 
vote

/** 
 * @return single instance
 */
public static synchronized Device getDevice(){
  Log.d(TAG,"Device: " + Build.DEVICE);
  if (instance == null) {
    Log.i(TAG,"Device: " + Build.DEVICE);
    if (Build.PRODUCT.equals("sdk")) {
      instance=new EmulatorDevice();
    }
 else     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
      instance=new FroyoDevice();
    }
 else     if (Build.DEVICE.startsWith("GT-")) {
      instance=new SamsungDevice();
    }
 else {
      instance=new DiscoverableDevice();
    }
    Log.i(TAG,"Interface: " + instance.getCell());
  }
  return instance;
}
 

Example 52

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/content/.

Source file: Project.java

  15 
vote

public void setDeviceData(Context context){
  deviceName=Build.MODEL;
  androidVersion=Build.VERSION.SDK_INT;
  if (context == null) {
    catroidVersionName="unknown";
    catroidVersionCode=0;
  }
 else {
    catroidVersionName=Utils.getVersionName(context);
    catroidVersionCode=Utils.getVersionCode(context);
  }
}
 

Example 53

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/com/binomed/showtime/android/.

Source file: CineShowTimeApplication.java

  15 
vote

@Override public Intent getMainApplicationIntent(){
  Intent startIntent=new Intent(getApplicationContext(),CineShowTimeMainActivity.class);
  if (Integer.valueOf(Build.VERSION.SDK) <= 10) {
    startIntent.putExtra(ParamIntent.ACTIVITY_LARGE_SCREEN,TestSizeOther.checkLargeScreen(getResources().getConfiguration().screenLayout));
  }
 else {
    startIntent.putExtra(ParamIntent.ACTIVITY_LARGE_SCREEN,TestSizeHoneyComb.checkLargeScreen(getResources().getConfiguration().screenLayout));
  }
  return startIntent;
}
 

Example 54

From project cocos2d, under directory /cocos2d-android/src/org/cocos2d/nodes/.

Source file: CCNode.java

  15 
vote

/** 
 * convenience methods which take a UITouch instead of CGPoint
 * @since v0.7.1
 */
public CGPoint convertTouchToNodeSpace(MotionEvent event){
  OneClassPool<CGPoint> pool=PoolHolder.getInstance().getCGPointPool();
  CGPoint point=pool.get();
  int action=event.getAction();
  int pid=action >> MotionEvent.ACTION_POINTER_ID_SHIFT;
  if (Build.VERSION.SDK_INT >= 5) {
    CCDirector.sharedDirector().convertToGL(Util5.getX(event,pid),Util5.getY(event,pid),point);
  }
 else {
    CCDirector.sharedDirector().convertToGL(event.getX(),event.getY(),point);
  }
  float x=point.x, y=point.y;
  pool.free(point);
  return convertToNodeSpace(x,y);
}
 

Example 55

From project com.juick.android, under directory /src/com/juick/android/.

Source file: ThreadFragment.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (Build.VERSION.SDK_INT >= 8) {
    mScaleDetector=new ScaleGestureDetector(getActivity(),new ScaleListener());
  }
}
 

Example 56

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  15 
vote

public void onConfigurationChanged(Configuration newConfig){
  setHasEmbeddedTabs(getResources_getBoolean(mContext,R.bool.abs__action_bar_embed_tabs));
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
    mActionView.onConfigurationChanged(newConfig);
    if (mContextView != null) {
      mContextView.onConfigurationChanged(newConfig);
    }
  }
}
 

Example 57

From project conference-mobile-app, under directory /android-app/src/com/google/android/apps/iosched/util/.

Source file: AnalyticsUtils.java

  15 
vote

private AnalyticsUtils(Context context){
  if (context == null) {
    return;
  }
  mApplicationContext=context.getApplicationContext();
  mTracker=GoogleAnalyticsTracker.getInstance();
  mTracker.start(UACODE,300,mApplicationContext);
  Log.d(TAG,"Initializing Analytics");
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mApplicationContext);
  final boolean firstRun=prefs.getBoolean(FIRST_RUN_KEY,true);
  if (firstRun) {
    Log.d(TAG,"Analytics firstRun");
    String apiLevel=Integer.toString(Build.VERSION.SDK_INT);
    String model=Build.MODEL;
    mTracker.setCustomVar(1,"apiLevel",apiLevel,VISITOR_SCOPE);
    mTracker.setCustomVar(2,"model",model,VISITOR_SCOPE);
    prefs.edit().putBoolean(FIRST_RUN_KEY,false).commit();
  }
}
 

Example 58

From project cornerstone, under directory /frameworks/base/services/java/com/android/server/am/.

Source file: ActivityManagerService.java

  15 
vote

private static ArrayList<ComponentName> readLastDonePreBootReceivers(){
  ArrayList<ComponentName> lastDoneReceivers=new ArrayList<ComponentName>();
  File file=getCalledPreBootReceiversFile();
  FileInputStream fis=null;
  try {
    fis=new FileInputStream(file);
    DataInputStream dis=new DataInputStream(new BufferedInputStream(fis,2048));
    int fvers=dis.readInt();
    if (fvers == LAST_DONE_VERSION) {
      String vers=dis.readUTF();
      String codename=dis.readUTF();
      String build=dis.readUTF();
      if (android.os.Build.VERSION.RELEASE.equals(vers) && android.os.Build.VERSION.CODENAME.equals(codename) && android.os.Build.VERSION.INCREMENTAL.equals(build)) {
        int num=dis.readInt();
        while (num > 0) {
          num--;
          String pkg=dis.readUTF();
          String cls=dis.readUTF();
          lastDoneReceivers.add(new ComponentName(pkg,cls));
        }
      }
    }
  }
 catch (  FileNotFoundException e) {
  }
catch (  IOException e) {
    Slog.w(TAG,"Failure reading last done pre-boot receivers",e);
  }
 finally {
    if (fis != null) {
      try {
        fis.close();
      }
 catch (      IOException e) {
      }
    }
  }
  return lastDoneReceivers;
}
 

Example 59

From project cow, under directory /libs/ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  15 
vote

public void onConfigurationChanged(Configuration newConfig){
  setHasEmbeddedTabs(mContext.getResources().getBoolean(R.bool.abs__action_bar_embed_tabs));
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
    mActionView.onConfigurationChanged(newConfig);
    if (mContextView != null) {
      mContextView.onConfigurationChanged(newConfig);
    }
  }
}
 

Example 60

From project creamed_glacier_app_settings, under directory /src/com/android/settings/.

Source file: DevelopmentSettings.java

  15 
vote

private void removeHdcpOptionsForProduction(){
  if ("user".equals(Build.TYPE)) {
    Preference hdcpChecking=findPreference(HDCP_CHECKING_KEY);
    if (hdcpChecking != null) {
      getPreferenceScreen().removePreference(hdcpChecking);
    }
  }
}
 

Example 61

From project cw-advandroid, under directory /Camera/Picture/src/com/commonsware/android/picture/.

Source file: PictureDemo.java

  15 
vote

@Override public void onResume(){
  super.onResume();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
    Camera.CameraInfo info=new Camera.CameraInfo();
    for (int i=0; i < Camera.getNumberOfCameras(); i++) {
      Camera.getCameraInfo(i,info);
      if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        camera=Camera.open(i);
      }
    }
  }
  if (camera == null) {
    camera=Camera.open();
  }
  startPreview();
}
 

Example 62

From project cw-android, under directory /APIVersions/ReadWriteStrict/src/com/commonsware/android/rwversions/.

Source file: StrictWrapper.java

  15 
vote

static public void init(){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
    new StrictForRealz();
  }
 else {
    new NotAllThatStrict();
  }
}
 

Example 63

From project cw-omnibus, under directory /ActionBar/ListNav/src/com/commonsware/android/listnav/.

Source file: ListNavFragmentDemoActivity.java

  15 
vote

@Override public void onCreate(Bundle state){
  super.onCreate(state);
  frag=(EditorFragment)getSupportFragmentManager().findFragmentById(android.R.id.content);
  if (frag == null) {
    frag=new EditorFragment();
    getSupportFragmentManager().beginTransaction().add(android.R.id.content,frag).commit();
  }
  if (state != null) {
    models=state.getCharSequenceArray(KEY_MODELS);
  }
  ArrayAdapter<String> nav=null;
  ActionBar bar=getSupportActionBar();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    nav=new ArrayAdapter<String>(bar.getThemedContext(),android.R.layout.simple_spinner_item,labels);
  }
 else {
    nav=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,labels);
  }
  nav.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
  bar.setListNavigationCallbacks(nav,this);
  if (state != null) {
    bar.setSelectedNavigationItem(state.getInt(KEY_POSITION));
  }
}