本文整理匯總了Java中org.appcelerator.titanium.TiApplication.getCurrentActivity方法的典型用法代碼示例。如果您正苦於以下問題:Java TiApplication.getCurrentActivity方法的具體用法?Java TiApplication.getCurrentActivity怎麽用?Java TiApplication.getCurrentActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.appcelerator.titanium.TiApplication
的用法示例。
在下文中一共展示了TiApplication.getCurrentActivity方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getActionBar
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
private ActionBar getActionBar(){
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return null;
}
try {
ActionBar actionBar = activity.getSupportActionBar();
return actionBar;
} catch (NullPointerException e) {
Log.e(TAG, "ActionBar is null (not found)");
return null;
}
}
示例2: handleSetStatusbarColor
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* Sets StatusbarColor for andoid 5.x / materialDesign
* @param obj
*/
private void handleSetStatusbarColor(String color){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return;
}
Window win = activity.getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
win.setStatusBarColor(TiConvert.toColor(color));
}
}
示例3: handleSetNavigationBarColor
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* Sets NavigationBarColor for Android 5.x / materialDesign
* @param obj
*/
private void handleSetNavigationBarColor(String color){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return;
}
Window win = activity.getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
win.setNavigationBarColor(TiConvert.toColor(color));
}
}
示例4: getStatusbarHeight
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* returns the height of the Statusbar as absolute pixels
* @return int statusbar height
*/
@Kroll.getProperty @Kroll.method
public int getStatusbarHeight() {
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return 0;
}
int result = 0;
int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = activity.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
示例5: searchDevices
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public boolean searchDevices()
{
Log.d(TAG, "searchDevices called");
//Halilk: if not enabled, enable bluetooth
enableBluetooth();
//Get Current activity//
TiApplication appContext = TiApplication.getInstance();
Activity activity = appContext.getCurrentActivity();
IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
activity.registerReceiver(myReceiver, intentFilter);
bluetoothAdapter.cancelDiscovery(); //cancel if it's already searching
bluetoothAdapter.startDiscovery();
return true;
}
示例6: BluetoothModule
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* @class BluetoothModule
* @constructor
* @return {BluetoothModule} The bluetooth namespace.
*/
public BluetoothModule()
{
super();
TiApplication appContext = TiApplication.getInstance();
Activity currentActivity = appContext.getCurrentActivity();
mContext = currentActivity.getBaseContext();
startService();
}
示例7: getModule
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public static TitaniumCountlyAndroidMessagingModule getModule() {
TitaniumCountlyAndroidMessagingModule module = null;
TiApplication appContext = TiApplication.getInstance();
Activity activity = appContext.getCurrentActivity();
Log.d(LCAT, "Activity:" + activity);
Log.d(LCAT, "lastinstance" + lastInstance);
if ((activity != null) && (lastInstance != null)) {
module = (TitaniumCountlyAndroidMessagingModule)lastInstance.get();
}
return module;
}
開發者ID:dieskim,項目名稱:countly-sdk-appcelerator-titanium-android,代碼行數:12,代碼來源:TitaniumCountlyAndroidMessagingModule.java
示例8: GaAndroidModule
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public GaAndroidModule()
{
super();
TiApplication appContext = TiApplication.getInstance();
activity = appContext.getCurrentActivity();
mInstance = GoogleAnalytics.getInstance(activity);
}
示例9: handleSetToolbarTopPadding
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* Set the padding of toolbar
* See http://developer.android.com/reference/android/support/v7/app/ActionBar.html#setHideOffset(int)
*
* @param Integer - value
*/
private void handleSetToolbarTopPadding(Object value){
try{
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return;
}
// Retrieve the AppCompact Toolbar
Toolbar toolbar = (Toolbar) activity.findViewById(TiRHelper.getResource("id.toolbar", true));
activity.setSupportActionBar(toolbar);
// Set the padding
toolbar.setPadding(0, TiConvert.toInt(value), 0, 0);
}catch(Exception e){
Log.e(TAG, e.toString());
}
}
示例10: makeDiscoverable
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public void makeDiscoverable()
{
if(bluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE)
{
TiApplication appContext = TiApplication.getInstance();
Activity activity = appContext.getCurrentActivity();
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
activity.startActivity(discoverableIntent);
}
}
示例11: handleDisableActionbarImage
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* Disables the actionbar's main custom image.
* @param obj
*/
private void handleDisableActionbarImage(){
ActionBar actionBar = getActionBar();
if (actionBar == null){
return;
}
View view = actionBar.getCustomView();
if (view == null) {
return;
}
try {
// Enable the title/subtitle text
actionBar.setDisplayShowTitleEnabled(true);
// Disable the custom layout
actionBar.setDisplayShowCustomEnabled(false);
// Find the image and release the bitmap
// Get a reference to the activity
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return;
}
// Fetching app package name and resources
String packageName = activity.getPackageName();
Resources resources = activity.getResources();
// If we made it here, then the bitmap object was set to something.
// Get the resource id for the ImageView
int resid_actionbar_centered_logo = resources.getIdentifier("actionbar_centered_logo", "id", packageName);
if (resid_actionbar_centered_logo != 0) {
// Find the ImageView
ImageView actionbar_centered_logo = (ImageView) view.findViewById(resid_actionbar_centered_logo);
if (actionbar_centered_logo != null) {
// Mark the image for garbage collection
Drawable drawable = actionbar_centered_logo.getDrawable();
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
bitmapDrawable.getBitmap().recycle();
}
// Set the ImageView to a transparent background
actionbar_centered_logo.setImageResource(android.R.color.transparent);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: connect
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public boolean connect(String devicemac)
{
if(devicemac == null)
return false;
//Check if we should use the service//
if(useService)
{
//Start Service//
try
{
//Get Current activity//
TiApplication appContext = TiApplication.getInstance();
Activity activity = appContext.getCurrentActivity();
BluetoothServiceIntent = new TiIntentWrapper(new Intent(activity,BluetoothService.class));
BluetoothServiceIntent.getIntent().putExtra("MacAddress",devicemac);
appContext.startService(BluetoothServiceIntent.getIntent());
return true;
}
catch(Exception e)
{
Log.w(TAG,"error on creating bluetooth service: "+e.getMessage());
return false;
}
}
else
{
bluetoothDevice = bluetoothAdapter.getRemoteDevice(devicemac);
if (bluetoothDevice.getBondState() == BluetoothDevice.BOND_NONE)
{
if(pairDevice(bluetoothDevice))
{
return socketConnect(bluetoothDevice);
}
else
{
postError("Could not pair device");
return false;
}
}
else
{
return socketConnect(bluetoothDevice);
}
}
}