List of usage examples for android.telephony TelephonyManager getDeviceId
@Deprecated
@SuppressAutoDoc
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getDeviceId()
From source file:org.ubicompforall.BusTUC.Queries.Browser.java
public String getRequestServer2(String stop, Boolean formated, double lat, double lon, int numStops, int dist, Context context) {// w ww . j a v a2s. c o m String html_string = null; HttpGet m_get = new HttpGet(); try { stop = URLEncoder.encode(stop, "UTF-8"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // HttpPost m_post= new // HttpPost("http://m.atb.no/xmlhttprequest.php?service=routeplannerOracle.getOracleAnswer&question="); try { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String t_id = tm.getDeviceId(); String tmp = "TABuss"; String p_id = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); m_get.setURI(new URI("http://busstjener.idi.ntnu.no/MultiBRISserver/MBServlet?dest=" + stop + "&lat=" + lat + "&long=" + lon + "&type=json&nStops=" + numStops + "&maxWalkDist=" + dist + "&key=" + tmp + p_id)); HttpResponse m_response = m_client.execute(m_get); // Request html_string = httpF.requestServer(m_response); // Will fail if server is busy or down Log.v("html_string", "Returned html: " + html_string); // Long newTime = System.nanoTime() - time; // System.out.println("TIMEEEEEEEEEEEEEEEEEEEEE: " + // newTime/1000000000.0); } catch (ClientProtocolException e) { Log.v("CLIENTPROTOCOL EX", "e:" + e.toString()); } catch (IOException e) { Log.v("IO EX", "e:" + e.toString()); } catch (NullPointerException e) { Log.v("NULL", "NullPointer"); } catch (StringIndexOutOfBoundsException e) { Log.v("StringIndexOutOfBounds", "Exception"); } catch (Exception e) { e.printStackTrace(); } return html_string; }
From source file:pl.poznan.put.cs.ify.api.group.YGroupFeature.java
/** * Creates communication object that can be used to send data to server. * This objects are automatically released when recipe is unregistered. * /* w w w . ja v a 2s . co m*/ * @param recipe * insert 'this' here * @param group * name of group, should be recipe's parameter * @param period * time between pooling server in seconds * @return */ public YComm createPoolingComm(YRecipe recipe, String group, int period) { TelephonyManager t = (TelephonyManager) mHost.getContext().getSystemService(Context.TELEPHONY_SERVICE); User u = mHost.getSecurity().getCurrentUser(); String login = u == null ? "" : u.name; String pass = u == null ? "" : u.hash; YUserData user = new YUserData(recipe.getName(), login, t.getDeviceId(), group, pass); final YComm comm = new YComm(recipe, user, this); PoolingSolution poolingSolution = new PoolingSolution(comm, mHost.getContext(), ((long) 1000) * period, getServerUrl(mHost.getContext())); mPoolingSollutions.put(comm, poolingSolution); return comm; }
From source file:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns the IMEI Number//from ww w . j a va2 s. co m */ public String getDeviceId() { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); try { deviceId = tm.getDeviceId(); if (deviceId == null || deviceId.length() == 0) deviceId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); } catch (Exception ex) { ex.printStackTrace(); } return deviceId; }
From source file:com.netdoers.utils.ApplicationLoader.java
private void sendRegistrationIdToBackend() { TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String currentSIMImsi = mTelephonyMgr.getDeviceId(); JSONObject jsonObject = getPushNotificationData(currentSIMImsi); Log.e("PUSH REGID SERVER---->>>>>>>>>>", jsonObject.toString()); SendToServerTask sendTask = new SendToServerTask(); sendTask.execute(new JSONObject[] { jsonObject }); }
From source file:com.almende.demo.conferenceApp.ConferenceAgent.java
/** * Inits the.// w w w. j a v a 2s .co m * * @param ctx * the ctx */ public void init(Context ctx) { ConferenceAgent.ctx = ctx; final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); final AgentConfig config = new AgentConfig(); config.setId(tm.getDeviceId()); final FileStateConfig stateConfig = new FileStateConfig(); stateConfig.setJson(true); stateConfig.setPath(ctx.getFilesDir().getAbsolutePath() + "/agentStates/"); stateConfig.setId("conferenceAgent"); config.setState(stateConfig); SimpleSchedulerConfig schedulerConfig = new SimpleSchedulerConfig(); config.setScheduler(schedulerConfig); loadConfig(config); if (!getState().containsKey(CONTACTKEY.getKey())) { getState().put(CONTACTKEY.getKey(), new HashMap<String, Info>()); } DetectionUtil.getInstance().startScan(); getScheduler().schedule(this.getRpc().buildMsg("refresh", null, null), DateTime.now().plus(60000)); reconnect(); }
From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity_layout); // Create the adapter that will return a fragment for each of the three primary sections of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// w ww .ja v a 2 s.c om public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE); ; SharedPreferences.Editor editor = settings.edit(); // load the default parameters into SharedPreferences for the first time launch int ct = settings.getInt("count", 0); if (ct == 0) { editor.putString("start", "9"); editor.putString("end", "21"); editor.putString("interval", "15"); editor.putString("duration", "5"); editor.putString("location", "On"); editor.putString("upload", "On"); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); editor.putString("IMEI", tm.getDeviceId()); editor.putString("brand", Build.BRAND); editor.putString("model", Build.MODEL); String phone_type = Build.BRAND + "_" + Build.MODEL; // motoX if (phone_type.equals("motorola_XT1058")) { editor.putString("mfcc_dist_same_semi", "13"); editor.putString("mfcc_dist_diff_semi", "18"); editor.putString("mfcc_dist_same_un", "13"); editor.putString("mfcc_dist_diff_un", "18"); } // nexus 4 else if (phone_type.equals("google_Nexus 4")) { editor.putString("mfcc_dist_same_semi", "17"); editor.putString("mfcc_dist_diff_semi", "22"); editor.putString("mfcc_dist_same_un", "17"); editor.putString("mfcc_dist_diff_un", "22"); } // s2 else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) { editor.putString("mfcc_dist_same_semi", "18"); editor.putString("mfcc_dist_diff_semi", "25"); editor.putString("mfcc_dist_same_un", "18"); editor.putString("mfcc_dist_diff_un", "25"); } // s3 else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) { editor.putString("mfcc_dist_same_semi", "16"); editor.putString("mfcc_dist_diff_semi", "21"); editor.putString("mfcc_dist_same_un", "16"); editor.putString("mfcc_dist_diff_un", "21"); } // s4 else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) { editor.putString("mfcc_dist_same_semi", "14"); editor.putString("mfcc_dist_diff_semi", "24"); editor.putString("mfcc_dist_same_un", "14"); editor.putString("mfcc_dist_diff_un", "24"); } // other devices else { editor.putString("mfcc_dist_same_semi", "15.6"); editor.putString("mfcc_dist_diff_semi", "21.6"); editor.putString("mfcc_dist_same_un", "15.6"); editor.putString("mfcc_dist_diff_un", "21.6"); Toast.makeText(this, "Your device is not recognized and the result might not be accurate...", Toast.LENGTH_SHORT).show(); } Log.i("Crowd++", "First time launched"); AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle("Welcome to Crowd++"); dialog.setMessage(Constants.hello_msg); dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20); } editor.putInt("count", ++ct); editor.commit(); Log.i("Launched Count", Integer.toString(ct)); mConst = new Constants(this); if (!Constants.calibration()) Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show(); }
From source file:org.esupportail.nfctagdroid.NfcTacDroidActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ESUP_NFC_TAG_SERVER_URL = getEsupNfcTagServerUrl(getApplicationContext()); //To keep session for desfire async requests CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); LocalStorage.getInstance(getApplicationContext()); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(getApplicationContext())); setContentView(R.layout.activity_main); mAdapter = NfcAdapter.getDefaultAdapter(this); checkHardware(mAdapter);// w w w. j av a2s. c o m localStorageDBHelper = LocalStorage.getInstance(this.getApplicationContext()); String numeroId = localStorageDBHelper.getValue("numeroId"); TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String imei = telephonyManager.getDeviceId(); url = ESUP_NFC_TAG_SERVER_URL + "/nfc-index?numeroId=" + numeroId + "&imei=" + imei + "&macAddress=" + getMacAddr() + "&apkVersion=" + getApkVersion(); view = (WebView) this.findViewById(R.id.webView); view.clearCache(true); view.addJavascriptInterface(new LocalStorageJavaScriptInterface(this.getApplicationContext()), "AndroidLocalStorage"); view.addJavascriptInterface(new AndroidJavaScriptInterface(this.getApplicationContext()), "Android"); view.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { if (progress == 100) { AUTH_TYPE = localStorageDBHelper.getValue("authType"); } } @Override public boolean onConsoleMessage(ConsoleMessage consoleMessage) { log.info("Webview console message : " + consoleMessage.message()); return false; } }); view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { view.reload(); return true; } }); view.getSettings().setAllowContentAccess(true); WebSettings webSettings = view.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDatabasePath(this.getFilesDir().getParentFile().getPath() + "/databases/"); view.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); view.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { } }); view.loadUrl(url); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:com.hollandhaptics.babyapp.BabyService.java
/** * @brief Entry point of the Service./*from ww w .j a v a 2 s.c o m*/ */ @SuppressLint("HardwareIds") @Override public void onCreate() { super.onCreate(); Log.d(TAG, "BabyService Created"); TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); imei = telephonyManager.getDeviceId(); Log.d(TAG, "IMEI: " + imei); upLoadServerUri = getResources().getString(R.string.file_upload_url); mhandler = new Handler(); // Get the directory for the app's audio recordings. File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "BabyApp"); if (!file.mkdirs()) { Log.e(TAG, "Directory not created"); } path = file.toString(); _recorder = new MediaRecorder(); }
From source file:com.drapp.FbLoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //this.getActionBar().hide(); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); setContentView(R.layout.fblogin);/*w w w. ja v a 2s . c om*/ loginButton = (LoginButton) findViewById(R.id.login_button); List<String> permissions = new ArrayList<String>(); permissions.add("email"); permissions.add("phone"); loginButton.setReadPermissions("email"); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { FbLoginActivity.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. // Toast.makeText(getApplicationContext(),user.getProperty("email").toString(),Toast.LENGTH_LONG).show() ; } }); TelephonyManager telephonyManager = (TelephonyManager) getSystemService( getApplicationContext().TELEPHONY_SERVICE); deviceid = telephonyManager.getDeviceId(); settings = getSharedPreferences(ConstValue.MAIN_PREF, 0); cd = new ConnectionDetector(this); btnLogin = (Button) findViewById(R.id.buttonLogin); btnRegister = (Button) findViewById(R.id.buttonRegister); btnLogin.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(FbLoginActivity.this, Login2Activity.class); startActivity(intent); } }); btnRegister.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(FbLoginActivity.this, RegisterActivity.class); startActivity(intent); } }); Button continuebtn = (Button) findViewById(R.id.button1); continuebtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(FbLoginActivity.this, MainActivity.class); startActivity(intent); finish(); } }); }
From source file:com.moodmap.SplashScreenActivity.java
private void getDeviceId(Context ctx) { final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice; tmDevice = "" + tm.getDeviceId(); spIDs.edit().putString("DeviceID", tmDevice).commit();// Saves device id // in shared // prefrence }