• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

error 400 bad request - invalid grant_type, when call google play developer API for getting subscrip

I am trying to read subscription details by using google play developer API but am seeing an interesting behavior. When running my app through Android Studio (as Debug variant) I am able to download objects. When I create a Signed APK (or run as Release variant) I am no longer able to download subscription detail by using google play developer API and receive a 400 bad request - invalid grant_type.

This is my authorization method:

try{
HttpTransport httpTransport = null;
httpTransport = new com.google.api.client.http.javanet.NetHttpTransport();

JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();

String applicationName = VariantConstants.AppName;
String packageName = VariantConstants.packageName;

final Set<String> scopes = Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER);

AssetManager am = context.getAssets();
InputStream inputStream = am.open("key.p12");


if(inputStream != null){
int SDK_INT = android.os.Build.VERSION.SDK_INT;
if (SDK_INT > 8) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);


GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId("service email")
.setServiceAccountScopes(scopes)
.setServiceAccountPrivateKeyFromP12File(inputStream)
.build();



AndroidPublisher pub = new AndroidPublisher.Builder
(httpTransport, jsonFactory, credential)
.setApplicationName(applicationName)
.build();


final AndroidPublisher.Purchases.Subscriptions.Get get =
pub.purchases().subscriptions().get(packageName,
VariantConstants.ONE_WEEK_SUB,
subscriptionDetail.getPurchaseToken());


final SubscriptionPurchase purchase = get.execute();

return purchase;
}
}else{
System.out.println("input Stream is null.");
}
}
/* catch (GeneralSecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} */
catch(Exception e){
System.out.println("getsubDetailFromGoogleApi :- Exception in method = " +e);
}

Printing out my credential, it looks like this when running: com.google.api.client.googleapis.auth.oauth2.GoogleCredential@42ed8060

and this when I receive an error: bpr@46096240 Since the issue occurs when creating a signed release.

Hopefully someone has seen this type of behavior before! Any help would be greatly appreciated!!

Do Not Disturb exceptions

Is it possible to allow sound through a Bluetooth speaker while Do not disturb is on? I love the DND feature while i sleep. But i also like to listen to a white noise app at night. I tried allowing both the Bluetooth feature and white noise app in the "allow exceptions" setting, but the Bluetooth speaker just silences. Any tips?

How to extract SMemo Notes locally on Galaxy S7 Active

[First: I don't want to use the cloud]
I have Notes written in the SMemo standard app on my Galaxy S7 Active phone, and I need to extract them to reload them on an other phone that is also a S7 Active, but not new, already in use, with some new SMemo notes already saved..
So I'd like to get the old SMemo files onto a flash drive. I'm not sure whether a backup app would be able to merge the old Notes files into the folder for the new Notes files, and I haven't found yet an app that can specifically backup the SMemo files? Searching with a file manager, I can't locate the Notes files generated by the SMemo app...
Please help
Thank you!

4g Bands (International to US) Question???

I just ordered the Galaxy FE 5G and I'm super f'n stoked. One reason is I will have BANDS for my network, unlike my Xiaomi (which at the time I didn't know could effect it).

I bought the International version of the S20 FE. Now looking at the bands in the photo, I could truly NEEEED band 71. USA model has it but international says it only goes to 66.

Since I'm going to be using here in the US on the metro/t-mobile network, will I be able to use the 71 band on the platform?

Attachments

  • IMG_20210323_224938.jpg
    IMG_20210323_224938.jpg
    99.6 KB · Views: 249

Activity crashing but I don't know why

Hello guys, as I said the activity is crashing. So I'm passing some values from an activity to another using multiple intent.putExtra() to another screen. I can't find why I does work. All helps are welcome.

Bellow is the code where I recover the putExtra()

Java:
public class StatusActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_status);

        TextView pHLevel = (TextView)findViewById(R.id.phLevel);
        TextView organicCLevel = (TextView)findViewById(R.id.organicCLevel);
        TextView nitrogenLevel = (TextView)findViewById(R.id.nitrogenlevel);
        TextView phosphorusLevel = (TextView)findViewById(R.id.phosphorusLevel);
        TextView potassiumLevel = (TextView)findViewById(R.id.potassiumLevel);
        TextView  zincLevel = (TextView)findViewById(R.id.zincLevel);
        TextView temperatureLevel = (TextView)findViewById(R.id.temparatureLevel);
        TextView date1 = (TextView)findViewById(R.id.date);
        String tempMessage="";
        String pHMessage="";
        String organicCMessage="";
        String nitrogenMessage="";
        String phosphorusMessage="";
        String potassiumMessage="";
        String zincMessage="";
        String username = getIntent().getStringExtra("username");
        double pH2 = Double.parseDouble(getIntent().getStringExtra("pH"));
        double organicC2 = Double.parseDouble(getIntent().getStringExtra("organicC"));
        double nitrogen2 = Double.parseDouble(getIntent().getStringExtra("nitrogen"));
        double phosphorus2 = Double.parseDouble(getIntent().getStringExtra("phosphorus"));
        double potassium2 = Double.parseDouble(getIntent().getStringExtra("potassium"));
        double zinc2 = Double.parseDouble(getIntent().getStringExtra("zinc"));
        double temp2 = Double.parseDouble(getIntent().getStringExtra("temp"));
        String date = getIntent().getStringExtra("date");

        //Temperature Level
        if (temp2 >= 24){
            tempMessage = temp2 + " is too high";
        }
        else if (temp2 >= 18 && temp2 <= 24){
            tempMessage = temp2 + " falls withing optimal temperature";
        }
        else if(temp2 < 18){
            tempMessage = temp2 + " temperature too low";
        }
        else
            tempMessage = "Incorrect reading";

        //pH Level
        if (pH2 >= 5.5 && pH2 <= 7.0){
            pHMessage = pH2 + " falls in optimal pH";
        }
        else if(pH2 < 5.5 && pH2>= 0){
            pHMessage = pH2 + " might be too acidic";
        }
        else if(pH2 >7 && pH2 <= 14){
            pHMessage = pH2 + " might be too alkaline";
        }
        else
            pHMessage = "Wrong Measurement!";

        //Organic carbon level
        if (organicC2 < 1.2){
            organicCMessage = "Low fertility";
        }
        else if(organicC2 >= 1.2 && organicC2 <= 1.7){
            organicCMessage = "Medium fertility";
        }
        else if(organicC2 > 1.7){
            organicCMessage = "High fertility";
        }else
            organicCMessage = "Wrong Measurement";

        //nitrogen Level
        if (nitrogen2 >= 0 && nitrogen2 < 15){
            nitrogenMessage = "Level too low";
        }
        else if (nitrogen2 >= 15 && nitrogen2 < 30){
            nitrogenMessage = "Medium level";
        }
        else if (nitrogen2 >= 30){
            nitrogenMessage = "High Level";
        }
        else
            nitrogenMessage = "Wrong measurement";

        //Phosphorus Level
        if (phosphorus2 >= 0 && phosphorus2 < 25){
            phosphorusMessage = "Level too low";
        }
        else if (phosphorus2 >= 25 && phosphorus2 < 50){
            phosphorusMessage = "Medium Level";
        }
        else if (phosphorus2 >= 50){
            phosphorusMessage = "High level";
        }
        else
            phosphorusMessage = "Wrong measurement";

        //potassium Level
        if (potassium2 >= 0 && potassium2 < 60){
            potassiumMessage = "Level too low";
        }
        else if (potassium2 >= 60 && potassium2 < 100){
            potassiumMessage = "Medium level";
        }
        else if (potassium2 >= 100){
            potassiumMessage = "High Level";
        }
        else
            potassiumMessage = "Wrong Measurement";

        //Zinc Level
        if (zinc2 >= 1.6 && zinc2 <= 3){
            zincMessage = "Level too low";
        }
        else if (zinc2 > 3 && zinc2 < 4){
            zincMessage = "Medium level";
        }
        if (zinc2 >= 4 && zinc2 <= 8){
            zincMessage = "High level";
        }
        else
            zincMessage = "Wrong measurement";


        date1.setText(date);
        /*pHLevel.setText(pHMessage);
        organicCLevel.setText(organicCMessage);
        nitrogenLevel.setText(nitrogenMessage);
        phosphorusLevel.setText(phosphorusMessage);
        potassiumLevel.setText(potassiumMessage);
        zincLevel.setText(zincMessage);
        temperatureLevel.setText(tempMessage);*/

    }
}

New build

My old desktop (from 2013 :eek:) was feeling a little long in the tooth, even though it had a few upgrades.

I thought it was time to build a new PC before this one crapped out on me. While I do have comprehensive backups, it's a pain to have to start from scratch when a box goes belly-up.

Here's the spec's.

CPU: Intel Core i7-9700F 3 GHz 8-Core Processor ($269.99 @ Adorama)
CPU Cooler: Thermaltake UX200 ARGB 43.34 CFM CPU Cooler ($40.99 @ Amazon)
Motherboard: ASRock B365M Pro4 Micro ATX LGA1151 Motherboard ($83.99 @ Amazon)
Memory: Corsair Vengeance LPX 32 GB (2 x 16 GB) DDR4-2400 CL16 Memory ($175.99 @ Amazon)
Storage: Samsung 970 Evo Plus 500 GB M.2-2280 NVME Solid State Drive ($74.98 @ Amazon)
Video Card: *MSI GeForce GTX 1050 Ti 4 GB GAMING X Video Card ($699.99 @ Amazon)
Case: Cooler Master MasterBox Q300L MicroATX Mini Tower Case ($48.49 @ Amazon)
Power Supply: Cooler Master MWE Gold 550 W 80+ Gold Certified Fully Modular ATX Power Supply ($89.99 @ Amazon)
Total: $1484.41
Prices include shipping, taxes, and discounts when available
*Lowest price parts chosen from parametric criteria
Generated by PCPartPicker 2021-03-24 13:04 EDT-0400


Before you get all "wow, you got wrapped helically around a central axis" one me, I know this is a very bad time to get certain components. That video card is really worth only about $175.00, definitely not $700.00. But that's what they are selling for new retail -- if you can find one. It's the perfect storm of COVID and Bitcoin. :(

I only listed in Part Picker because that's what I already had here and will be waiting to get a better card once prices and supply normalize. Or, maybe not. After all, I'm not a gamer (unless you count scrabble :p). My needs are more in line with Photoshop, web development and some 3D modelling. Maybe the odd video or animation.

So after a few snags -- namely an EVGA 650W 80+ gold power supply that showed up DOA, and doing my mother-in-laws taxes -- I was able to finish it up.

Photos for your critical review.

PXL_20210324_161105341.jpg PXL_20210324_161203793.jpg PXL_20210324_161215629.jpg PXL_20210324_161244800.jpg

Apps App crash after trying to retrieve data from sqlite

Hi guys, I'm currently facing a problem, after inserting data on activity, after pressing the send button, another activity is loaded on which the most recent data stored in the database is loaded in displayed in a TextView.
But each time I pressed the send button, when the app redirect me to the next activity it crashed and I dunno why. If you could help me, I thank you in advance.

Below the DBHelper.java

Java:
public Cursor getDataSoilData(String username){
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.rawQuery("Select pH, OCarbon, nitrogen, phosphorus, potassium, zinc, temparature, date from soilData where username = ? ORDER BY id DESC LIMIT 1", new String[] {username}, null);
        return cursor;
    };

Below the activity that is fetching the data
Java:
public class StatusActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_status);

        Button viewData = (Button)findViewById(R.id.submitBtn);
        TextView pHLevel = (TextView)findViewById(R.id.phLevel);
        TextView organicCLevel = (TextView)findViewById(R.id.organicCLevel);
        TextView nitrogenLevel = (TextView)findViewById(R.id.nitrogenlevel);
        TextView phosphorusLevel = (TextView)findViewById(R.id.phosphorusLevel);
        TextView potassiumLevel = (TextView)findViewById(R.id.potassiumLevel);
        TextView  zincLevel = (TextView)findViewById(R.id.zincLevel);
        TextView temperatureLevel = (TextView)findViewById(R.id.temparatureLevel);
        TextView date1 = (TextView)findViewById(R.id.date);
        String tempMessage;
        String pHMessage;
        String organicCMessage;
        String nitrogenMessage;
        String phosphorusMessage;
        String potassiumMessage;
        String zincMessage;
        DBHelper db = new DBHelper(this);
        String username = getIntent().getStringExtra("username");
        Cursor cursor = db.getDataSoilData(username);
        StringBuilder pH = new StringBuilder();
        StringBuilder organicC1 = new StringBuilder();
        StringBuilder nitrogen1 = new StringBuilder();
        StringBuilder phosphorus1 = new StringBuilder();
        StringBuilder potassium1 = new StringBuilder();
        StringBuilder zinc1 = new StringBuilder();
        StringBuilder temp = new StringBuilder();
        StringBuilder date = new StringBuilder();;
        while(cursor.moveToNext()){
            pH.append(cursor.getDouble(2));
            organicC1.append(cursor.getDouble(3));
            nitrogen1.append(cursor.getDouble(4));
            phosphorus1.append(cursor.getDouble(5));
            potassium1.append(cursor.getDouble(6));
            zinc1.append(cursor.getDouble(7));
            temp.append(cursor.getDouble(8));
            date.append(cursor.getString(9));
        }

Help - android studio emulator

Hello.

I am currently working on an app in Android Studio. However, I've come across a problem.
I can't run the emulator anymore and I don't know why. I used to be able to run it, but after having created a database and made some extra changes, I can't run it anymore.

I am trying to fix the problem, but I have no clue how. It is very frustrating!!! can anyone please help a guy in need, please?

I have attached a picture of what it looks like when I try to run it.

Thank you!!
-Balos

Attachments

  • Screenshot 2021-03-24 at 16.56.14.png
    Screenshot 2021-03-24 at 16.56.14.png
    169.4 KB · Views: 212

Apps Null Pointer Exception after taking their refrences

Hello Guys
I am stuck at some point in my Android Project.
Java:
 public void initStreamerInfo() {

        ImageView streamerAvatar= findViewById(R.id.livestreamingHeader_streamerImage);
        TextView streamerName = findViewById(R.id.livestreamingHeader_name);
        TextView streamerAge = findViewById(R.id.livestreamingHeader_age);
        followingImg = findViewById(R.id.livestreamingHeader_followedStreamer);
        if (streamerAvatar==null){
            Log.d("statusofimgvw","kuch nhi ho sakta");
        }
        else {
            Log.d("statusofimgvw","Not null");
        }
        User puser=mLiveStreamObject.getAuthor();
        Log.d("checkingvaluel",puser.getProfilePhotos().get(puser.getAvatarPhotoPosition()).getUrl());
        Log.d("checkingvaluel",puser.getColFirstName());
        Log.d("checkingvaluel"," "+mLiveStreamObject.getAuthor().getProfilePhotos());
        QuickHelp.getAvatars(mLiveStreamObject.getAuthor(), streamerAvatar);
        streamerName.setText(String.format("%s, ", mLiveStreamObject.getAuthor().getColFirstName()));

        if (mLiveStreamObject.getAuthor().getBirthDate() != null){
            streamerAge.setText(String.valueOf(QuickHelp.getAgeFromDate(mLiveStreamObject.getAuthor().getBirthDate())));
        }

        setTimer(mLiveStreamObject.getStartedAt());

        FollowModel.queryFollowSingleUser(mLiveStreamObject.getAuthor(), new FollowModel.QueryFollowListener() {
            @Override
            public void onQueryFollowSuccess(boolean isFollowing) {

                if (isFollowing){
                    followingImg.setVisibility(View.VISIBLE);
                    isFollowingUser  = true;
                } else {
                    followingImg.setVisibility(View.GONE);
                    isFollowingUser  = false;
                }
            }

            @Override
            public void onQueryFollowError(ParseException error) {
                followingImg.setVisibility(View.GONE);
                isFollowingUser  = false;
            }
        });
    }


It's my java code where I am initializing the xml components and using them.
Java:
 public static void getAvatars(User user, ImageView imageView){

        ColorDrawable colorDrawable = new ColorDrawable(ContextCompat.getColor(Application.getInstance().getApplicationContext(), R.color.highlight_light_ripple));

        // Load profile Photos
        if (user.getProfilePhotos() != null && user.getProfilePhotos().size() > 0) {

            Glide.with(Application.getInstance().getApplicationContext())
                    .load(user.getProfilePhotos().get(user.getAvatarPhotoPosition()).getUrl())
                    .error(colorDrawable)
                    .centerCrop()
                    .circleCrop()
                    .fitCenter()
                    .placeholder(colorDrawable)
                    .into(imageView);

        } else {

            Glide.with(Application.getInstance().getApplicationContext())
                    .load(colorDrawable)
                    .into(imageView);
        }
    }

It's the method named getAvatars in another class named QuickHelp.
Code:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <View
        android:id="@+id/imageCenterView"
        android:layout_width="1dp"
        android:layout_height="1dp"
        app:layout_constraintBottom_toBottomOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintEnd_toEndOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintStart_toStartOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintTop_toTopOf="@+id/livestreamingHeader_streamerImage" />

    <com.sos.GD_Live.modules.circularimageview.CircleImageView
        android:id="@+id/livestreamingHeader_streamerImage"
        android:layout_width="@dimen/icon_xlg"
        android:layout_height="@dimen/icon_xlg"
        android:layout_marginStart="@dimen/spacing_md"
        android:layout_marginTop="@dimen/spacing_md"
        android:layout_marginBottom="@dimen/spacing_md"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="@dimen/spacing_md" />

    <TextView
        android:id="@+id/livestreamingHeader_status"
        style="?attr/textStyleP3Inverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="26dp"
        android:padding="1dp"
        android:text="00:00"
        android:background="@drawable/bg_livestreaming_rounded_rect_red_carrot"
        app:layout_constraintBottom_toBottomOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintEnd_toEndOf="@+id/imageCenterView"
        app:layout_constraintStart_toStartOf="@+id/imageCenterView"
        app:layout_constraintTop_toBottomOf="@+id/livestreamingHeader_streamerImage" />

    <LinearLayout
        android:id="@+id/livestreamingHeader_streamerInfo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/spacing_sm"
        android:layout_marginEnd="@dimen/spacing_md"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        app:layout_constraintBottom_toTopOf="@+id/livestreamingHeader_subtitle"
        app:layout_constraintStart_toEndOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintTop_toTopOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintVertical_chainStyle="packed"
        android:layout_marginRight="@dimen/spacing_md"
        android:layout_marginLeft="@dimen/spacing_sm">

        <TextView
            android:id="@+id/livestreamingHeader_name"
            style="?attr/textStyleP2Inverse"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:maxWidth="@dimen/streamer_name_max_width"
            android:maxLines="1"
            tools:text="Maravilho, "
            android:singleLine="true" />

        <TextView
            android:id="@+id/livestreamingHeader_age"
            style="?attr/textStyleP2Inverse"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            tools:text="25"
            android:maxLines="1" />

        <ImageView
            android:id="@+id/livestreamingHeader_followedStreamer"
            style="?attr/textStyleP2Inverse"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="4dp"
            android:visibility="gone"
            app:srcCompat="@drawable/ic_livestream_favorites_streamer"
            android:layout_marginLeft="4dp" />
    </LinearLayout>

    <TextView
        android:id="@+id/livestreamingHeader_subtitle"
        style="?attr/textStyleP3Inverse"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/spacing_md"
        android:alpha="0.5"
        android:ellipsize="end"
        android:maxWidth="120dp"
        android:maxLines="1"
        android:singleLine="true"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@+id/livestreamingHeader_streamerInfo"
        app:layout_constraintTop_toBottomOf="@+id/livestreamingHeader_streamerInfo"
        app:layout_constraintVertical_chainStyle="packed"
        android:layout_marginRight="@dimen/spacing_md" />
</merge>

it's my xml code.

The error is that when I executing this code it shows me null pointer exception on accessing each view after taking refrence also.

Thanks in Advance

Filter

Back
Top Bottom