本文整理匯總了Java中com.bluecats.sdk.BCBeacon.BCProximity類的典型用法代碼示例。如果您正苦於以下問題:Java BCProximity類的具體用法?Java BCProximity怎麽用?Java BCProximity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BCProximity類屬於com.bluecats.sdk.BCBeacon包,在下文中一共展示了BCProximity類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import com.bluecats.sdk.BCBeacon.BCProximity; //導入依賴的package包/類
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
mBinding = DataBindingUtil.setContentView( this, R.layout.activity_beacons );
setSupportActionBar( mBinding.toolbar );
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled( true );
final Intent intent = getIntent();
mSite = intent.getParcelableExtra( BlueCatsSDK.EXTRA_SITE );
setTitle( mSite.getName() );
final BeaconsTabAdapter tabAdapter = new BeaconsTabAdapter( getSupportFragmentManager(), Arrays.asList(
BeaconProximityFragment.newInstance( mSite, BCProximity.BC_PROXIMITY_IMMEDIATE ),
BeaconProximityFragment.newInstance( mSite, BCProximity.BC_PROXIMITY_NEAR ),
BeaconProximityFragment.newInstance( mSite, BCProximity.BC_PROXIMITY_FAR ),
BeaconProximityFragment.newInstance( mSite, BCProximity.BC_PROXIMITY_UNKNOWN )
) );
mBinding.viewPager.setAdapter( tabAdapter );
mBinding.tabLayout.setupWithViewPager( mBinding.viewPager );
mBinding.tabLayout.setTabTextColors( Color.argb( 128, 255, 255, 255 ), Color.WHITE );
/*
* LOCAL NOTIFICATION EXAMPLE
*/
final BCLocalNotification localNotification = new BCLocalNotification( NOTIFICATION_ID );
// can add an optional site to trigger in
//BCSite site = new BCSite();
//site.setSiteID("SITE_ID_HERE");
//site.setName("SITE_NAME_HERE");
//localNotification.setFireInSite(site);
// optional time to trigger the event after, eg 10 seconds from now
localNotification.setFireAfter( new Date( new Date().getTime() + ( 10 * 1000 ) ) );
// add a category or several categories to trigger the notification
final BCCategory category = new BCCategory();
category.setName( "CATEGORY_NAME" );
final List<BCCategory> categories = new ArrayList<>();
categories.add( category );
localNotification.setFireInCategories( categories );
// can add an optional proximity to trigger event
localNotification.setFireInProximity( BCProximity.BC_PROXIMITY_IMMEDIATE );
// set alert title and content
localNotification.setAlertContentTitle( "ALERT_TITLE" );
localNotification.setAlertContentText( "ALERT_CONTENT" );
// launch icon and ringtone are optional. will just default ringtone and app icon for defaults
localNotification.setAlertSmallIcon( R.mipmap.ic_launcher );
localNotification.setAlertSound( RingtoneManager.getDefaultUri( RingtoneManager.TYPE_NOTIFICATION ) );
// this controls where the notification takes you.
// can also contain a bundle or any extra info that you might want to unpack
final Intent contentIntent = new Intent( BeaconsActivity.this, SitesActivity.class );
localNotification.setContentIntent( contentIntent );
BCLocalNotificationManager.getInstance().scheduleLocalNotification( localNotification );
}