Java Code Examples for com.adobe.fre.FREContext#getActivity()

The following examples show how to use com.adobe.fre.FREContext#getActivity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationInit.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public FREObject call(FREContext ctx, FREObject passedArgs[]) {
// Log.d("Alex", "NotificationInit");
		try {
			Intent intent = new Intent(ctx.getActivity(), NotificationActivity.class);
			PendingIntent pendingIntent = PendingIntent.getActivity(ctx.getActivity(),
				1, intent, PendingIntent.FLAG_UPDATE_CURRENT);

			builder = new Notification.Builder(ctx.getActivity())
			.setSmallIcon(android.R.drawable.stat_sys_download_done)
			.setContentTitle("VPN-over-DNS")
			.setContentIntent(pendingIntent)
			.setContentText("Running");

			Notification n;
			if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) {
				n = builder.build();
			} else {
				n = builder.getNotification();
			}
			/* http://www.laurivan.com/android-make-your-notification-sticky/ */
			n.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;

			manager = 
				(NotificationManager) ctx.getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
			manager.notify(1, n);

			
		} catch (IllegalStateException e) {
			e.printStackTrace();
		}

		return null;
	}
 
Example 2
Source File: Context.java    From google-play-game-services-ane with MIT License 5 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] args) {

	Intent sign = new Intent(context.getActivity(),
			SignInActivity.class);
	context.getActivity().startActivity(sign);
	return null;
}
 
Example 3
Source File: Achievements.java    From google-play-game-services-ane with MIT License 5 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] arg1) {

	Intent intent = new Intent(context.getActivity(), StubActivity.class);
	intent.setAction(StubActivity.ACTION_SHOW_ACHIEVEMENTS_ACTIVITY);
	context.getActivity().startActivity(intent);
	return null;
}
 
Example 4
Source File: Leaderboards.java    From google-play-game-services-ane with MIT License 5 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] args) {
	

	Intent intent = new Intent(context.getActivity(), StubActivity.class);
	intent.setAction(StubActivity.ACTION_SHOW_LEADERBOARD_BY_ID_ACTIVITY);
	context.getActivity().startActivity(intent);
	return null;
}
 
Example 5
Source File: GetApiKeyFunction.java    From ANE-Crashlytics with Apache License 2.0 5 votes vote down vote up
public FREObject call(FREContext context, FREObject[] args) {
	super.call(context, args);
	
	try {
		Activity activity = context.getActivity();
		ApplicationInfo ai = activity.getPackageManager().getApplicationInfo(activity.getPackageName(), PackageManager.GET_META_DATA);
	    String apiKey = ai.metaData.getString("io.fabric.ApiKey");
		return FREObject.newObject(apiKey);
	}
	catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
Example 6
Source File: PurchaseFunction.java    From AndroidInAppPurchase with Apache License 2.0 5 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1)
{	
	try
	{
		if(Billing.getInstance().activity() == null) //don't start another activity, if there is one already
		{
			FREObject sku = arg1[0];
			FREObject type = arg1[1];
			FREObject payload = arg1[2];
			
			if(sku == null || sku.getAsString().length() == 0)
				Billing.getInstance()._ctx.dispatchStatusEventAsync("PURCHASE_ERROR", "Invalid product id.");
			else if(type == null || type.getAsString().length() == 0)
				Billing.getInstance()._ctx.dispatchStatusEventAsync("PURCHASE_ERROR", "Invalid purchase type.");
			else //everything's ok
			{
				Billing.getInstance().schedulePurchase(sku.getAsString(), type.getAsString(), (payload == null ? null : payload.getAsString()));
			
				Intent intent = new Intent(arg0.getActivity(), BillingActivity.class);
				arg0.getActivity().startActivity(intent);
			}
		}
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
	
	return null;
}