List of usage examples for android.content Context getApplicationContext
public abstract Context getApplicationContext();
From source file:cn.sharesdk.analysis.util.PreferencesHelper.java
private PreferencesHelper(Context mContext) { context = mContext.getApplicationContext(); packageName = context.getPackageName(); }
From source file:com.ibm.demo.IoTStarter.utils.MqttHandler.java
private MqttHandler(Context context) { this.context = context; this.app = (IoTStarterApplication) context.getApplicationContext(); this.client = null; }
From source file:org.wso2.iot.agent.services.DeviceInfoPayload.java
public DeviceInfoPayload(Context context) { this.context = context.getApplicationContext(); deviceInfo = new DeviceInfo(context); mapper = new ObjectMapper(); registrationId = Preference.getString(context, Constants.FCM_REG_ID); phoneState = new DeviceState(context); }
From source file:com.jaredrummler.android.device.DeviceName.java
/** * Create a new request to get information about a device. * * @param context/*w ww.j a va 2s . co m*/ * the application context * @return a new Request instance. */ public static Request with(Context context) { return new Request(context.getApplicationContext()); }
From source file:com.jaredrummler.android.device.DeviceName.java
/** * Get the {@link DeviceInfo} for the current device. Do not run on the UI thread, as this may * download JSON to retrieve the {@link DeviceInfo}. JSON is only downloaded once and then * stored to {@link SharedPreferences}.//w ww . jav a2 s. c o m * * @param context * the application context. * @return {@link DeviceInfo} for the current device. */ public static DeviceInfo getDeviceInfo(Context context) { return getDeviceInfo(context.getApplicationContext(), Build.DEVICE, Build.MODEL); }
From source file:com.example.android.uamp.playback.CastPlayback.java
public CastPlayback(MusicProvider musicProvider, Context context) { mMusicProvider = musicProvider;//from w ww. j a va 2 s . c o m mAppContext = context.getApplicationContext(); CastSession castSession = CastContext.getSharedInstance(mAppContext).getSessionManager() .getCurrentCastSession(); mRemoteMediaClient = castSession.getRemoteMediaClient(); mRemoteMediaClientListener = new CastMediaClientListener(); }
From source file:org.wso2.emm.agent.services.DeviceInfoPayload.java
public DeviceInfoPayload(Context context) { this.context = context.getApplicationContext(); deviceInfo = new DeviceInfo(context); mapper = new ObjectMapper(); registrationId = Preference.getString(context, Constants.FCM_REG_ID); phoneState = new DeviceState(context); locationService = LocationServiceImpl.getInstance(context); }
From source file:com.foxykeep.datadroid.requestmanager.RequestManager.java
protected RequestManager(Context context, Class<? extends RequestService> requestService) { mContext = context.getApplicationContext(); mRequestService = requestService;/*from ww w . j a v a 2 s . c om*/ mRequestReceiverMap = new HashMap<Request, RequestReceiver>(); mMemoryCache = new LruCache<Request, Bundle>(30); }
From source file:es.deustotech.piramide.utils.tts.TextToSpeechWeb.java
private static synchronized void speech(final Context context, final String text, final String language) { executor.submit(new Runnable() { @Override/* w ww. j a va 2 s . c om*/ public void run() { try { final String encodedUrl = Constants.URL + language + "&q=" + URLEncoder.encode(text, Encoding.UTF_8.name()); final DefaultHttpClient client = new DefaultHttpClient(); HttpParams params = new BasicHttpParams(); params.setParameter("http.protocol.content-charset", "UTF-8"); client.setParams(params); final FileOutputStream fos = context.openFileOutput(Constants.MP3_FILE, Context.MODE_WORLD_READABLE); try { try { final HttpResponse response = client.execute(new HttpGet(encodedUrl)); downloadFile(response, fos); } finally { fos.close(); } final String filePath = context.getFilesDir().getAbsolutePath() + "/" + Constants.MP3_FILE; final MediaPlayer player = MediaPlayer.create(context.getApplicationContext(), Uri.fromFile(new File(filePath))); player.start(); Thread.sleep(player.getDuration()); while (player.isPlaying()) { Thread.sleep(100); } player.stop(); } finally { context.deleteFile(Constants.MP3_FILE); } } catch (InterruptedException ie) { // ok } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:org.cvasilak.jboss.mobile.admin.net.TalkToJBossServerTask.java
public TalkToJBossServerTask(Context context, Server server, Callback callback) { this.context = context; this.client = CustomHTTPClient.getHttpClient(); this.server = server; this.callback = callback; this.gjson = ((JBossAdminApplication) context.getApplicationContext()).getJSONParser(); this.parser = new JsonParser(); // enable digest authentication if (server.getUsername() != null && !server.getUsername().equals("")) { Credentials credentials = new UsernamePasswordCredentials(server.getUsername(), server.getPassword()); client.getCredentialsProvider().setCredentials( new AuthScope(server.getHostname(), server.getPort(), AuthScope.ANY_REALM), credentials); }/*from w w w.jav a2 s . c o m*/ }