List of usage examples for android.view Display getHeight
@Deprecated public int getHeight()
From source file:com.paperpad.mybox.GcmBroadcastReceiver.java
/** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. * @param regId //from ww w . j a v a2 s . c o m */ private void sendRegistrationIdToBackend(Context context, String regId) { int id_menu = 0; String application_unique_identifier = Installation.id(context); String application_version = "0.2.8"; try { application_version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ; String device_type = ""; boolean isTablet = context.getResources().getBoolean(R.bool.isTablet); if (isTablet) { device_type = "tablet"; } else { device_type = "smartphone"; } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); } else { size.x = display.getWidth(); // deprecated size.y = display.getHeight(); } String device_screen_resolution = size.x + "x" + size.y; // ArrayList<AppHit> hits = new ArrayList<AppHit>(); AppSession appSession = new AppSession(id_menu, "production", "MyBox", application_unique_identifier, application_version, regId, Build.MANUFACTURER, Build.MODEL, "android", device_screen_resolution, 5, Build.VERSION.SDK_INT + "", device_type, "", System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, null); ArrayList<AppSession> appSessions = new ArrayList<AppSession>(); appSessions.add(appSession); AppJsonWriter appJsonWriter = new AppJsonWriter(); String str = appJsonWriter.writeJson(appSessions); String endpoint = SERVER_URL; String body = str; int status = 0; try { status = AppJsonWriter.post(endpoint, body); } catch (IOException e) { Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status); e.printStackTrace(); } }
From source file:com.paperpad.MoulinsDuDuc.GcmBroadcastReceiver.java
/** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. * @param regId //from w w w . j a va 2s.c o m */ private void sendRegistrationIdToBackend(Context context, String regId) { int id_menu = 0; String application_unique_identifier = Installation.id(context); String application_version = "0.2.8"; try { application_version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ; String device_type = ""; boolean isTablet = context.getResources().getBoolean(R.bool.isTablet); if (isTablet) { device_type = "tablet"; } else { device_type = "smartphone"; } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); } else { size.x = display.getWidth(); // deprecated size.y = display.getHeight(); } String device_screen_resolution = size.x + "x" + size.y; // ArrayList<AppHit> hits = new ArrayList<AppHit>(); AppSession appSession = new AppSession(id_menu, "production", "MyBox", application_unique_identifier, application_version, regId, android.os.Build.MANUFACTURER, android.os.Build.MODEL, "android", device_screen_resolution, 5, android.os.Build.VERSION.SDK_INT + "", device_type, "", System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, null); ArrayList<AppSession> appSessions = new ArrayList<AppSession>(); appSessions.add(appSession); AppJsonWriter appJsonWriter = new AppJsonWriter(); String str = appJsonWriter.writeJson(appSessions); String endpoint = SERVER_URL; String body = str; int status = 0; try { status = AppJsonWriter.post(endpoint, body); } catch (IOException e) { Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status); e.printStackTrace(); } }
From source file:com.ztspeech.weibo.sdk.renren.view.RenrenDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progress = new ProgressDialog(getContext(), R.style.mydialog); progress.requestWindowFeature(Window.FEATURE_NO_TITLE); progress.setMessage("..."); progress.setCanceledOnTouchOutside(false); content = new LinearLayout(getContext()); content.setOrientation(LinearLayout.VERTICAL); requestWindowFeature(Window.FEATURE_NO_TITLE); if (this.showTitle) { setUpTitle();// ww w . j a v a 2 s . c o m } setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); float scale = getContext().getResources().getDisplayMetrics().density; float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }
From source file:com.acrylicgoat.scrumnotes.DailyNotesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dailynotes); aBar = getActionBar();/*from w w w.j ava 2 s. co m*/ aBar.setTitle(getString(R.string.app_name)); aBar.setDisplayHomeAsUpEnabled(true); //goals = (EditText) findViewById(R.id.editGoals); note = (EditText) findViewById(R.id.editDaily); Display d = getWindowManager().getDefaultDisplay(); if (isTabletDevice(d, this)) { if (d.getWidth() < d.getHeight()) { //in portrait so give more lines note.setLines(20); } else { note.setLines(11); } } getNotes(); String[] items = getResources().getStringArray(R.array.nav_list); setDrawer(items); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); SimpleAdapter sAdapter = new SimpleAdapter(this, navTitles, R.layout.nav_drawer, from, to); // Set the adapter for the list view //drawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list_item, navTitles)); // Set the list's click listener drawerList.setOnItemClickListener(new DrawerItemClickListener()); drawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ drawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; drawerToggle.setDrawerIndicatorEnabled(true); drawerToggle.syncState(); drawerLayout.setDrawerListener(drawerToggle); aBar.setDisplayHomeAsUpEnabled(true); aBar.setHomeButtonEnabled(true); drawerList.setAdapter(sAdapter); }
From source file:com.euphor.paperpad.GcmBroadcastReceiver.java
/** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. * @param regId /*w w w . java 2s . c om*/ */ private void sendRegistrationIdToBackend(Context context, String regId) { int id_menu = MainActivity.params.getId(); String application_unique_identifier = Installation.id(context); String application_version = "0.2.8"; try { application_version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ; String device_type = ""; if (MainActivity.isTablet) { device_type = "tablet"; } else { device_type = "smartphone"; } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); } else { size.x = display.getWidth(); // deprecated size.y = display.getHeight(); } String device_screen_resolution = size.x + "x" + size.y; ArrayList<AppHit> hits = new ArrayList<AppHit>(); AppSession appSession = new AppSession(id_menu, MainActivity.prod_or_sand, "sales", application_unique_identifier, application_version, regId, Build.MANUFACTURER, Build.MODEL, "android", device_screen_resolution, 5, Build.VERSION.SDK_INT + "", device_type, "", System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, hits); ArrayList<AppSession> appSessions = new ArrayList<AppSession>(); appSessions.add(appSession); AppJsonWriter appJsonWriter = new AppJsonWriter(); String str = appJsonWriter.writeJson(appSessions); String endpoint = SERVER_URL; String body = str; int status = 0; try { status = AppJsonWriter.post(endpoint, body); } catch (IOException e) { Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status); e.printStackTrace(); } }
From source file:com.harmazing.aixiumama.activity.ActivityGallery.java
private Bitmap GetandSaveCurrentImage() { //Bitmap// www.ja va 2s . c o m WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); int w = display.getWidth(); int h = display.getHeight(); Bitmap Bmp = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); //?? View decorview = this.getWindow().getDecorView(); // decorview.setDrawingCacheEnabled(true); // decorview.buildDrawingCache(); // Bmp = decorview.getDrawingCache(); Canvas c = new Canvas(Bmp); decorview.draw(c); // Bmp = Bitmap.createBitmap(Bmp, 0, BitmapUtil.dip2px(getApplicationContext(), 50) + getTopViewHeight(), w, CuteApplication.getScreenHW(getApplicationContext())[0] - BitmapUtil.dip2px(getApplicationContext(), 10)); decorview.destroyDrawingCache(); decorview.setDrawingCacheEnabled(false); return Bmp; }
From source file:im.vector.activity.ImageWebViewActivity.java
@SuppressLint("NewApi") private Point getDisplaySize() { Point size = new Point(); WindowManager w = getWindowManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { w.getDefaultDisplay().getSize(size); } else {/* ww w. ja v a 2 s .co m*/ Display d = w.getDefaultDisplay(); size.x = d.getWidth(); size.y = d.getHeight(); } return size; }
From source file:ir.rasen.charsoo.view.widgets.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from ww w . j a v a2 s . c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(Color.parseColor(TAB_HOST_UNSELECTED_TEXT_COLOR)); // get screen size int measuredWidth = 0; int measuredHeight = 0; WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); w.getDefaultDisplay().getSize(size); measuredWidth = size.x; measuredHeight = size.y; } else { Display d = w.getDefaultDisplay(); measuredWidth = d.getWidth(); measuredHeight = d.getHeight(); } textView.setLayoutParams( new ViewGroup.LayoutParams(measuredWidth / tabCount, ViewGroup.LayoutParams.MATCH_PARENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.iStudy.Study.Renren.View.RenrenDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progress = new ProgressDialog(getContext()); progress.requestWindowFeature(Window.FEATURE_NO_TITLE); progress.setMessage("Loading..."); content = new LinearLayout(getContext()); content.setOrientation(LinearLayout.VERTICAL); requestWindowFeature(Window.FEATURE_NO_TITLE); if (this.showTitle) { setUpTitle();/*from w w w . j av a 2s . c o m*/ } setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); float scale = getContext().getResources().getDisplayMetrics().density; @SuppressWarnings("deprecation") float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }
From source file:com.pac.performance.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (mWidth == 1 || mHeight == 1) { Display display = getWindowManager().getDefaultDisplay(); mWidth = display.getWidth();/* w w w. ja va 2s . c o m*/ mHeight = display.getHeight(); } setContentView(R.layout.activity_main); CPUChange = BatteryChange = AudioChange = VoltageChange = IOChange = MinFreeChange = VMChange = false; mFragments.clear(); mFragmentNames.clear(); // add CPU Fragment mFragments.add(new CPUFragment()); mFragmentNames.add(getString(R.string.cpu)); // add Battery Fragment if (Utils.exist(FAST_CHARGE) || Utils.exist(BLX)) { mFragments.add(new BatteryFragment()); mFragmentNames.add(getString(R.string.battery)); } // add Audio Fragment if (Utils.exist(FAUX_SOUND_CONTROL)) { mFragments.add(new AudioFragment()); mFragmentNames.add(getString(R.string.audio)); } // add Voltage Fragment if (Utils.exist(VoltageHelper.CPU_VOLTAGE) || Utils.exist(VoltageHelper.FAUX_VOLTAGE)) { mFragments.add(new VoltageFragment()); mFragmentNames.add(getString(R.string.voltage)); } // add IO Fragment mFragments.add(new IOFragment()); mFragmentNames.add(getString(R.string.io)); // add MinFree Fragment mFragments.add(new MinFreeFragment()); mFragmentNames.add(getString(R.string.minfree)); // add VM Fragment if (VMHelper.getVMValues().size() == VMHelper.getVMFiles().size()) { mFragments.add(new VMFragment()); mFragmentNames.add(getString(R.string.vm)); } // add Information Fragment mFragments.add(new InformationFragment()); mFragmentNames.add(getString(R.string.information)); Utils.saveString("kernelversion", Utils.getFormattedKernelVersion(), getApplicationContext()); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.fragment_list, mFragmentNames)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1, android.R.id.text1, mFragmentNames), this); if (savedInstanceState == null) { setPerm(); Fragment fragment = new ViewPagerFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); selectItem(0); } }