I have a working app made with Xamarin.Android, and I'm trying to add in-app purchases with the component Xamarin.InAppBilling v2.2
I use this code with my public key from the Google Play Developer Console.
_serviceConnection = new InAppBillingServiceConnection(activity, InAppBillingPublicKey);
_serviceConnection.OnConnected += LoadProducts;
_serviceConnection.Connect();
It fails with this exception message: "Service Intent must be explicit: Intent { act=com.android.vending.billing.InAppBillingService.BIND }"
I can find others talking about this for plain android development, but not for Xamarin and this component. How do I make the component have the service intent set explicitly? Is there another way to to in-app-purchases in Xamarin.Android?
From other posts, I have found and tried this:
var intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
intent.SetPackage("com.android.vending");
activity.BindService(intent, _serviceConnection, Bind.AutoCreate);
But it still won't work. I get the same error.
The error goes away i I set API level to 19 (was 21). But then I get another error from the linker. But for this case, it solves the problem.
Related
I'm trying to implement an 'Open on phone' button on a Wear OS app, but am unable to import the RemoteIntent class.
When I add import com.google.android.wearable.intent.RemoteIntent to my MainActivity.java the wearable is underlined in red with a 'Cannot resolve symbol' error.
Do I need to add a particular dependency to my project for this to be available?
The docs for RemoteIntent don't give me any clues as to what I might be missing.
For context, I am trying to use the following snippet in my app:
private void openOnPhone(Uri uri) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
RemoteIntent.startRemoteActivity(this, intent, null);
// 'Open on phone' confirmation overlay
new ConfirmationOverlay().setType(ConfirmationOverlay.OPEN_ON_PHONE_ANIMATION).setMessage("Opened on phone").showOn(this);
}
You need to import:
androidx.wear:wear-remote-interactions:1.0.0
Then instead use something like:
RemoteActivityHelper(application).startRemoteActivity(
Intent(Intent.ACTION_VIEW).apply {
addCategory(Intent.CATEGORY_DEFAULT)
.addCategory(Intent.CATEGORY_BROWSABLE)
data = Uri.parse("some://uri")
},
null
)
However, this library does require compileSdkVersion 31 (Android 12)
I think you need to add one or both of the following dependencies:
androidx.wear:wear-phone-interactions:1.0.0-beta01
androidx.wear:wear-remote-interactions:1.0.0-beta01
It's mentioned in the release notes here. There's also a note about renaming it that might be relevant to you:
We have added the RemoteIntentHelper class (previously RemoteIntent in
the Wearable Support Library) which can be used for opening intents on
other devices (i.e. from watch to phone). (I1d7e0)
This package:
implementation 'com.google.android.support:wearable:2.8.1'
I'm working with espresso for testing. I'm following Espresso Intents
and problem happened when I try to work like this site. First is validateIntentSentToPackage method:
public void validateIntentSentToPackage() {
user.clickOnView(system.getView(R.id.callButton));
intended(toPackage("com.android.phone"));}
Android Studio display error at "user" and "system". I don't understand this error what does this mean.
Second is activityResult_IsHandledProperly method:
public void activityResult_IsHandledProperly() {
Intent resultData = new Intent();
String phoneNumber = "123-345-6789";
resultData.putExtra("phone", phoneNumber);
ActivityResult result = new ActivityResult(Activity.RESULT_OK, resultData);
intending(toPackage("com.example.unittestdemo")).respondWith(result));
onView(withId(R.id.pickButton)).perform(click());
onView(withId(R.id.phoneNumber).check(matches(withText(phoneNumber)));}
Android Studio display error java.lang.NullPointerException and in line intending(toPackage("com.example.unittestdemo")).respondWith(result);
Please help!!!
Android Studio display error at "user" and "system". I don't understand this error what does this mean.
I guess, you don't have previously declared these variables.
I don't see any logs or whole code of this testing class, so I can only recommend you to check this example
Here you would find all methods which you're looking for in one file.
Also please visit Google Samples - Espresso Testing repository
For inAppBilling in my app use Bazaar(Iranian Android Market) API.
All things are right but in in Android 5 Lollipop this not work correctly and return error :
After many search found this similar problem and this link too this one.(solutions are similar together)
So I try to adding this line :
serviceIntent.setPackage("ir.cafebazaar.pardakht");
After this line:
Intent serviceIntent = new Intent("ir.cafebazaar.pardakht.InAppBillingService.BIND");
Now app return this Errors :
java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.isEmpty()' on a null object reference
at farahang.tedAmouz.BzrBl.util.IabHelper.Setuping(IabHelper.java:227)
at farahang.tedAmouz.adapters.slideMenuAdapter.onClick(slideMenuAdapter.java:155)
Codes work completely-correctly in under Android 5 Lollipop versions just have problem with Android 5 Lollipop!
For binding play services we do something like this:
Intent i = new Intent("com.android.vending.billing.InAppBillingService.BIND");
i.setPackage("com.android.vending");
mContext.bindService(e, this.serviceConnection, Context.BIND_AUTO_CREATE);
Maybe there is something wrong with your setPackage replace it with
i.setPackage("com.farsitel.bazaar");
Instead of
i.setPackage("ir.cafebazaar.pardakht");
I'm trying to build a simple Hello World GDK program for Google Glass. I've looked up everywhere, but all the samples I could find used "Timeline Manager", which was removed by Google after XE 16.
What I'm trying to do is to create a live card that shows texts (Hello world!) in the middle.
I've tried to modify codes from HERE (HuskyHuskie's answer) and HERE (IsabelHM's answer)
However, no matter what I did, no option or voice command appeared on the glass even though the console showed that the program is installed on device.
What I mostly modified was take out the TimelineManager part and replace
mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
with
mLiveCard = new LiveCard(this,LIVE_CARD_ID);
Also, I'm relatively new to Android. I don't quite understand how R.id.XXXX and R.layout.XXXX are missing from the resource. Do you need to define it in Manifest or what else?
The following is the onStartCommand method:
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
RemoteViews aRV = new RemoteViews(this.getPackageName(),
R.layout.card_text);
if (mLiveCard == null) {
// mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
mLiveCard = new LiveCard(this,LIVE_CARD_ID);
aRV.setTextViewText(R.id.main_text, INTRO);
mLiveCard.setViews(aRV);
Intent mIntent = new Intent(this, MainActivity.class);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
mLiveCard.setAction(PendingIntent.getActivity(this, 0, mIntent, 0));
mLiveCard.publish(LiveCard.PublishMode.REVEAL);
}
return START_STICKY;
}
Ok I got it to work following THIS
Note that the Manifest is not entirely correct. You need to add this line in the Manifest after the XE16 update:
<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
See the post HERE for reference.
I strongly recommend using our official samples available on GitHub and reading our documentations as all of those caveats are explained and handled.
If you are using the latest version of Android Studio, you can also easily create a new project through our available templates: LiveCard and Immersion.
Open Android Studio
Create a new project
Enter your project information: application name, package name, etc.
Select Glass as the form factor: make sure to unselect all the other form factors unless you want to develop for those devices as well.
Select the Immersion Activity or the Simple Live Card template
Build and run your new Hello World project on Glass!
in agreement with the recent post from Android Developers http://android-developers.blogspot.pt/2013/10/getting-your-sms-apps-ready-for-kitkat.html ,I was trying to prepare my app to the new android version, but encountered a problem with the part they suggest to create a dialog to let the user set the app as the default application to handle SMS's :
Android Developers Post
public class ComposeSmsActivity extends Activity {
#Override
protected void onResume() {
super.onResume();
final String myPackageName = getPackageName();
if (!Telephony.Sms.getDefaultSmsPackage(this).equals(myPackageName)) {
// App is not default.
// Show the "not currently set as the default SMS app" interface
View viewGroup = findViewById(R.id.not_default_app);
viewGroup.setVisibility(View.VISIBLE);
// Set up a button that allows the user to change the default SMS app
Button button = (Button) findViewById(R.id.change_default_app);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent =
new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,
myPackageName);
startActivity(intent);
}
});
} else {
// App is the default.
// Hide the "not currently set as the default SMS app" interface
View viewGroup = findViewById(R.id.not_default_app);
viewGroup.setVisibility(View.GONE);
}
}
}
the code itself in pretty much straightforward, but I'm unable to access to Telephony.Sms.getDefaultSmsPackage because it says that Telephony cannot be resolved, and I can't find any import or declaration that would fix that.
Can anyone please help?
android.provider.Telephony simply doesn't exist yet (as of API 18 - 4.3).
This class will be added in 4.4 (presumably API 19), and that blog post is highlighting the changes that you should make once the new API is released so you aren't surprised when the time comes.
From the end of the post:
To help you make the changes, we'll soon be providing the necessary SDK components for Android 4.4 that allow you to compile and test your changes on Android 4.4.
Don't forget that you should wrap this code in an API version check so you don't run into issues with older versions that don't have this class.
this change will break all the SMS blocking apps.
"Note that—beginning with Android 4.4—any attempt by your app to abort the SMS_RECEIVED_ACTION broadcast will be ignored so all apps interested have the chance to receive it."
Do you think there is a way to go around this?!
Maybe at least on Root?
Apparently there is with root access. The latest version Cerberus app claim to be doing this.
Now, if only I knew how they do it :(