PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Wednesday, December 14, 2022

[FIXED] What does this mean "xmlns:xliff"? XML

 December 14, 2022     android, syntax, xliff, xml     No comments   

Issue

What does this mean?

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

It can be seen in Strings.xml as part of the resources folder values in Android projects.


Solution

This is xml namespace used for xliff. Xliff is used for localization purposes. You can read more about xliff here.



Answered By - inazaruk
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, November 27, 2022

[FIXED] How to import multi-module SDK project by exposing its core module only

 November 27, 2022     android, dependencies, gradle, maven, module     No comments   

Issue

I am developing a project which should work as an Android sdk, the project includes:

  • an app module for demo
  • a module called mainSdkModule
  • other minor modules that are used in the mainSdkModule (lets say moduleA and moduleB)

the mainSdkModule imports moduleA and moduleB this way:

implementation project(':moduleA')
implementation project(':moduleB')

I am publishing the whole project as an SDK that I want to use in another app project. To test the integration of this SDK I am temporarily publishing it to my local maven folder. What happens is that when I import the sdk into the app project, the build fails with the following error:

Could not find sdk-main-package:moduleA:unspecified.
Required by:
    project :mainSdkModule > sdk-main-package:core:1.0.0

I could avoid this error by publishing each module as an indipendent library but I need to keep them internal without exposing them.

Is it normal that the app project asks for a dependency that isn't even supposed to be visible by other projects besides the sdk one? How can I include moduleA and moduleB inside the core and grant access to them for those who import the SDK without exposing these internal modules on maven?


Solution

Modules A and B are declared as external dependencies and will be referenced as such in the pom.xml file. Something like this:

<dependency>
   <groupId>sdk-main-package</groupId>
   <artifactId>moduleA</artifactId>
   <version>unspecified</version>
   <scope>compile</scope>
</dependency>

What you want is to create a fat jar or a fat aar. A fat jar/aar is a jar/aar file that also includes the dependencies (instead of referencing them as external dependencies). I don't know if your SDK needs to be a jar file or an aar file and if you don't know either then you can find out the difference e.g. here: Android Archive Library (aar) vs standard jar.

If you need a fat jar then you can use the Shadow plugin: https://imperceptiblethoughts.com/shadow/introduction.

If you need a fat aar then you can e.g. use this: https://medium.com/android-news/android-fat-aar-from-gradle-892038facc87. There are other solutions but I haven't personally tested any of them so don't know which ones really work. If you google fat aar you'll get plenty of hits and I hope one of them solves your problem.



Answered By - Emanuel Moecklin
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to import multi-module SDK project by exposing its core module only

 November 27, 2022     android, dependencies, gradle, maven, module     No comments   

Issue

I am developing a project which should work as an Android sdk, the project includes:

  • an app module for demo
  • a module called mainSdkModule
  • other minor modules that are used in the mainSdkModule (lets say moduleA and moduleB)

the mainSdkModule imports moduleA and moduleB this way:

implementation project(':moduleA')
implementation project(':moduleB')

I am publishing the whole project as an SDK that I want to use in another app project. To test the integration of this SDK I am temporarily publishing it to my local maven folder. What happens is that when I import the sdk into the app project, the build fails with the following error:

Could not find sdk-main-package:moduleA:unspecified.
Required by:
    project :mainSdkModule > sdk-main-package:core:1.0.0

I could avoid this error by publishing each module as an indipendent library but I need to keep them internal without exposing them.

Is it normal that the app project asks for a dependency that isn't even supposed to be visible by other projects besides the sdk one? How can I include moduleA and moduleB inside the core and grant access to them for those who import the SDK without exposing these internal modules on maven?


Solution

Modules A and B are declared as external dependencies and will be referenced as such in the pom.xml file. Something like this:

<dependency>
   <groupId>sdk-main-package</groupId>
   <artifactId>moduleA</artifactId>
   <version>unspecified</version>
   <scope>compile</scope>
</dependency>

What you want is to create a fat jar or a fat aar. A fat jar/aar is a jar/aar file that also includes the dependencies (instead of referencing them as external dependencies). I don't know if your SDK needs to be a jar file or an aar file and if you don't know either then you can find out the difference e.g. here: Android Archive Library (aar) vs standard jar.

If you need a fat jar then you can use the Shadow plugin: https://imperceptiblethoughts.com/shadow/introduction.

If you need a fat aar then you can e.g. use this: https://medium.com/android-news/android-fat-aar-from-gradle-892038facc87. There are other solutions but I haven't personally tested any of them so don't know which ones really work. If you google fat aar you'll get plenty of hits and I hope one of them solves your problem.



Answered By - Emanuel Moecklin
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, November 22, 2022

[FIXED] How to obtain transaction id or other information in paypal mobile SDK

 November 22, 2022     android, paypal, paypal-mobile-sdk, paypal-sandbox     No comments   

Issue

I have recently implement paypal mobile payment tutorial using following tutorial: http://androiddevelopmentanddiscussion.blogspot.com/2014/05/paypal-integration-in-android.html

and in response i get following information:

{
    "response": {
        "state": "approved",
        "id": "PAY-1GM934738N157023RKR7OWYI",
        "create_time": "2014-12-03T10:52:17Z",
        "intent": "sale"
    },
    "client": {
        "platform": "Android",
        "paypal_sdk_version": "2.1.0",
        "product_name": "PayPal-Android-SDK",
        "environment": "sandbox"
    },
    "response_type": "payment"
}




{
    "short_description": "Painting 1",
    "amount": "8",
    "intent": "sale",
    "currency_code": "USD"
}

any one guide me how can i obtain transaction id and other information in mobile sdk? as i see payment from paypal mobile sdk id is different then the actual transaction id.

any help would be appreciated.


Solution

You can retrieve a payment resource using the payment ID returned by the SDK: https://developer.paypal.com/webapps/developer/docs/api/#look-up-a-payment-resource

Typically, this would be done from your server and not from the mobile device. The GET operation will require an access token generated using both your client_id and client_secret.

Updated links:

  • getting a payment resource: https://developer.paypal.com/docs/api/payments/#payment_get
  • REST authentication and headers: https://developer.paypal.com/docs/api/auth-headers/


Answered By - Matt Jacunski
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, November 19, 2022

[FIXED] What are the requirements for audio output in Chrome on Android?

 November 19, 2022     android, audio, google-chrome, javascript, twilio-php     No comments   

Issue

I'm using code from here: https://github.com/TwilioDevEd/video-quickstart-php to develop a webRTC web app.

The example application, when running successfully on 2 browsers, creates the following HTML:

  <div id="remote-media">
  <audio src="blob:https%3A//myAddress.com/8a537e34-9ab2-4bea-a85d-61e5f80b585c"></audio>
  <video src="blob:https%3A//myAddress.com/22b23b46-9021-4f15-9ab5-ffb78fec2d48"></video>
  </div>
  
  <div id="local-media">
  <audio src="blob:https%3A//myAddress.com/740c8e33-cc60-4d1e-b1fe-2c23742e618d"></audio>
  <video src="blob:https%3A//myAddress.com/3105d4a2-cd71-4408-8b7c-771cba677829"></video>
  </div>

It works on Chrome and Firefox on a PC, and works on Firefox on Android.

Chrome on Android connects, there is video and audio input which is visible and audible on the remote browser, and there is video output - the video streamed from the remote browser. THE PROBLEM: there is no audio output.

I have tried $("audio").autoplay="true"; in the javascript that creates the <audio> element.

I have opened other web pages from the same Chrome installation on the same device (eg. YouTube) and I have audio and video.

What am I missing?


Solution

"On iOS, and Chrome for Android, autoplay doesn’t work; users must tap the screen to play the video." source: https://developers.google.com/web/fundamentals/design-and-ui/media/video/quick-reference?hl=en#autoplay

My solution:

      <button id="audioOn" onclick="$('#remote-media > audio')[0].play()">Cant hear? Click me!</button>


Answered By - grateful
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] What is Twilio's SMS verification gradle dependency?

 November 19, 2022     android, twilio, twilio-php     No comments   

Issue

I am using Twilio for SMS verification to my android app using Android Studio, and I found this Dependency from Twilio official documentation(compile 'com.twilio: verification:+'), here is the link: https://www.twilio.com/docs/guides/twilio-verification-sdk-integration-guide/integrating-twilio-verification-sdk-using-sample-backend#step-3-add-twilio-verification-sdk-for-android

but as add this dependency, the Gradle shows error and can not be built, here I have already asked my answer: Error:Failed to resolve: com.google.android.gms:play-services-auth-api-phone:10.2.5

Is there anyone who knows what is the exact dependency of Twilio Verification to add in my Android Studio to use Twilio SMS verification.


Solution

another Twilio developer evangelist here.

The issue with that document is that it fails to mention that you will need to use a local Google Play services SDK for the time being until Google releases it out in the wild.

To get that, all you need to do is fill up the form in this page to get the SDK, and the in your code you will do the following:

  1. Open ~/.gradle/gradle.properties
  2. add PARTNER_SDK_DIR=/Users/{USER_NAME}/workspace/partner-sdk
  3. Import the SDK

So you should end up with somthing that looks like this:

allprojects {
    repositories {
        maven {
            url PARTNER_SDK_DIR
        }
        jcenter()
    }
}

We have a sample application on our github repository which you can download and test. You will find it here

Hope this helps you!



Answered By - Marcos Placona
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, November 18, 2022

[FIXED] How to center widgets vertically when orientation is horizontal for an Android LinearLayout?

 November 18, 2022     android, android-linearlayout, listview, listviewitem, vertical-alignment     No comments   

Issue

I have several different item view types in an Android ListView, each with its own LinearLayout. I am trying to center all of their widgets vertically in addition to their being placed horizontally relative to each other. See the the very first item in the ListView in the attached pic. It looks fine except that the widgets are pushed up near the top of the ListView item.

The light blue and light green backgrounds for the TextView and ImageViews are intended to help view the effects of the xml on placement. Immediately below the image is my layout for that topmost item in the ListView. How can I make the TextView as well as the circular images (ImageView) to be centered vertically?

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="5dp">

        <TextView
            android:id="@+id/ques_num"
            android:layout_width="30dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_marginTop="2dp"
            android:layout_marginBottom="2dp"
            android:background="@color/LightBlue"
            android:text="0."
            android:textSize="22sp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="center_vertical"
            android:background="@color/LightGreen"
            android:adjustViewBounds="true"
            android:id="@+id/question_id_0" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="center_vertical"
            android:background="@color/LightGreen"
            android:adjustViewBounds="true"
            android:id="@+id/question_id_1" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="center_vertical"
            android:background="@color/LightGreen"
            android:adjustViewBounds="true"
            android:id="@+id/question_id_2" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="center_vertical"
            android:background="@color/LightGreen"
            android:adjustViewBounds="true"
            android:id="@+id/question_id_3" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="center_vertical"
            android:background="@color/LightGreen"
            android:adjustViewBounds="true"
            android:id="@+id/question_id_4" />


</LinearLayout>

UPDATE:

I tried simply adding to the LinearLayout:

android:gravity="center_horizontal"

and afterwards tried changing it to:

android:gravity="center_horizontal|center_vertical"

In both cases it resulted in moving the widgets into the horizontal center of the ListView item, but had no effect on the vertical positioning. See the results here in the image:

enter image description here


Solution

The entire problem was a combination of this line in the LinearLayout:

android:paddingBottom="5dp"

and the fact that, given the size of the content in the TextView and ImageView objects, the upper and lower boundaries of the ListView items were already pressing in as much as they could. There was no room for centering adjustments to take place even though it looked like there was, because of the paddingBottom attribute.



Answered By - Alyoshak
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] Why vertical orientation does not render images vertically?

 November 18, 2022     android, android-recyclerview, vertical-alignment     No comments   

Issue

My .xml file has the following code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
     android:orientation="vertical"
     android:id="@+id/image_list"
     android:layout_width="match_parent"
     android:layout_height="match_parent"/>
</LinearLayout>

However, the phone renders images as follows:

enter image description here

Why?


Solution

Are you setting a LayoutManager for the RecyclerView? See this documentation.

setLayoutManager

void setLayoutManager (RecyclerView.LayoutManager layout)

Set the RecyclerView.LayoutManager that this RecyclerView will use.

In contrast to other adapter-backed views such as ListView or GridView, RecyclerView allows client code to provide custom layout arrangements for child views. These arrangements are controlled by the RecyclerView.LayoutManager. A LayoutManager must be provided for RecyclerView to function.



Answered By - Cheticamp
Answer Checked By - Mary Flores (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, November 17, 2022

[FIXED] How to make a ProgressBar stay in the center of screen despite scrolling

 November 17, 2022     android, vertical-alignment     No comments   

Issue

I have a ProgressBar in a ScrollView, and I'd like it to stay centered vertically despite the user scrolling down or up. However, I'm not sure how to accomplish this.

Here's the code that I have, simple as it is. I have an indeterminate ProgressBar:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/ocr_scroll_view"
android:layout_width="match_parent"
android:layout_height="fill_parent">

    <RelativeLayout android:id="@+id/image_holder"
    android:layout_gravity="end"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

        <ImageView android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

        <ProgressBar android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleLarge"
        android:visibility="gone"
        android:layout_centerInParent="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

And I call it as such:

    spinningProgressBar = (ProgressBar)findViewById(R.id.progressBar1);
    spinningProgressBar.setIndeterminate(true);
    spinningProgressBar.setVisibility(View.GONE);

Setting its visibility at the appropriate times.

All suggestions very much appreciated.


Solution

Put it outside of the ScrollView. Just have the ScrollView and the ProgressBar overlap.

You can read about how to overlap views here: Overlapping Views in Android

There's a couple of ways to do it, ranging from GridLayouts to RelativeLayouts and then programatic ways to do it.



Answered By - Alex K
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, November 16, 2022

[FIXED] how to create vertical slider in android by @react-native-community/slider?

 November 16, 2022     android, javascript, react-native, slider, vertical-alignment     No comments   

Issue

enter image description here
As the title and picture, how to create vertical slider in android by @react-native-community/slider? I try to create a slider like: <Slider vertical={true}/> but it's not working.


Solution

After searching, I finally found a solution Use transform css to rotate 90deg component https://reactnative.dev/docs/transforms



Answered By - Hai Quan Le
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to make text centered vertically in Android compose?

 November 16, 2022     android, android-jetpack-compose, text, vertical-alignment     No comments   

Issue

I am working on my first app fully designed by Compose.

I need to centralize vertically text with the Text() compose component. In traditional Android dev practice I did this over alignment property. Text() compose also has alignment property, but at this moment it has limited capacity (Alignment.Horizontal() is only allowed), despite on I noticed different alignment values within Text() when made a research in web. Similar case for Column() - it also has alignment property .wrapContentSize() and also has limitation on values that could be used here, despite on quick research in web shows it may receive CenterVertically too.

What is your way to achieve this visual effect? The full code piece is below

@ExperimentalUnitApi
@Composable
fun TripBookingContent(state: PassengerTripUiState.TripBookUiState) {
    Log.d(App.TAG, "[screen] TripBookingContent")
    val baselineGrid = dimensionResource(id = R.dimen.baseline_grid)
    val mainPadding = dimensionResource(id = R.dimen.main_margin_compact)
    var componentSpace = dimensionResource(id = R.dimen.component_space)
    Column(
        modifier = Modifier
            .wrapContentHeight()
            .fillMaxWidth()
            .padding(
                paddingValues = PaddingValues(
                    horizontal = mainPadding,
                    vertical = baselineGrid
                )
            )
    ) {
        TripViewItem(
            data = state.trip,
            {},
            modifier = Modifier.padding(vertical = baselineGrid)
        )
        Text(
            text = stringResource(id = R.string.booking_screen_driver),
            color = colorResource(id = R.color.white),
            style = TextStyle(textIndent = TextIndent(firstLine = TextUnit(16F, TextUnitType.Sp))),
            modifier = Modifier
                .height(componentSpace)
                .padding(start = baselineGrid)
                .fillMaxWidth()
                .background(color = colorResource(id = R.color.design_default_color_secondary_variant))
        )
        Log.d(App.TAG, "[state] state.driver - ${state}")
        Log.d(App.TAG, "[state] state.driver.toDriver() - ${state.driver}")
        DriverCardContent(data = state.driver)

        Text(
            text = stringResource(id = R.string.booking_screen_msg),
            color = colorResource(id = R.color.white),
            style = TextStyle(textIndent = TextIndent(firstLine = TextUnit(16F, TextUnitType.Sp))),
            textAlign = TextAlign.Center,
            modifier = Modifier
//                .height(componentSpace)
                .height(32.dp)
                .padding(start = baselineGrid)
                .fillMaxWidth()
                .background(color = colorResource(id = R.color.colorPrimaryDark))
        )
        /**
         * Disable book button at current (alfa version), for more details
         * */
        Button(
            onClick = { /* no op */ },
            modifier = Modifier
                .alpha(0F)
                .fillMaxWidth()
                .padding(baselineGrid)
                .height(dimensionResource(id = R.dimen.button_height)),
            colors = ButtonDefaults.buttonColors(
                backgroundColor = Color.Blue,
                contentColor = Color.White
            ),
        ) {
            Text(
                text = stringResource(id = R.string.booking_screen_confirm_button),
                modifier = Modifier.align(Alignment.CenterVertically),
                fontWeight = FontWeight.Bold
            )
        }
    }
}

UPDATE My final solution become this one below. I have to move padding and background to the Box() layer to achieve text in center both vertically and horizontally.

        Box(
            contentAlignment = Alignment.Center,
            modifier = Modifier
                .height(32.dp)
                .padding(start = baselineGrid)
                .fillMaxWidth()
                .background(color = colorResource(id = R.color.colorPrimaryDark))
        ) {
            Text(
                text = stringResource(id = R.string.booking_screen_msg),
                color = colorResource(id = R.color.white),
                style = TextStyle(textIndent = TextIndent(firstLine = TextUnit(16F, TextUnitType.Sp))),
                textAlign = TextAlign.Center,
/*                modifier = Modifier
//                .height(componentSpace)
                    .height(32.dp)
                    .padding(start = baselineGrid)
                    .fillMaxWidth()
                    .background(color = colorResource(id = R.color.colorPrimaryDark))*/
            )
        } 

Solution

It's not possible to center vertically only using Text(). I asked similar question here, you need to use Box() with contentAlignment = Alignment.Center. There are also CenterStart and CenterEnd options for alignment either.

   Box(
        contentAlignment = Alignment.Center,
    ) {
        Text(
            text = "Text",
            textAlign = TextAlign.Center
        )
    }


Answered By - Thracian
Answer Checked By - Katrina (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, November 14, 2022

[FIXED] Why and how the exception in any thread crashes the whole app in Android

 November 14, 2022     android, error-handling, exception, java, multithreading     No comments   

Issue

If I spawn a thread in activity and throw an exception like this

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    Thread {
        throw java.lang.RuntimeException()
    }.start()
}

This will crash the app with FATAL ERROR

If I do equivalent in a pure Java program, the main thread will continue to run. For example:

public class ThreadTest {
    public static void main(String args[]) {
        System.out.println("Start ");

        new Thread(){
            public void run() {
                System.out.println("Inner Start");
                throw new RuntimeException();
            }
        }.start();
        try{
            Thread.sleep(3000);
            System.out.println("End");
        }catch(Exception ignored){ }
    }
}

The output will be

Start 
Inner Start
Exception in thread "Thread-0" java.lang.RuntimeException
    at ThreadTest$1.run(ThreadTest.java:17)
End

What causes this difference in behaviour?


Solution

Because the Android Runtime is what actually kills your Android app. Both the behavior of the Java and the Android code are perfectly compliant with the Java Language Specification, which states:

If no catch clause that can handle an exception can be found, 
then the **current thread** (the thread that encountered the exception) is terminated

however, in the section about program termination it also states this:

A program terminates all its activity and exits when one of two things happens:

* All the threads that are not daemon threads terminate.

* Some thread invokes the exit method of class Runtime or class System, and the exit operation is not forbidden by the security manager.

While this may make it feel like the Android implementation is non-compliant, that is isn't the case. The JLS says that it must terminate if all threads are terminated, but it doesn't say "an different process can't terminate the program if it detects that one thread is terminated", and the Android Runtime, which is not a JVM and is a different process can terminate the process when it detects an exception. Note that this behavior is similar in native Android code as Android documentation states:

* An app that is written using Java or Kotlin crashes
if it throws an unhandled exception, represented by the Throwable class.
* An app that is written using native-code languages crashes 
if there’s an unhandled signal, such as SIGSEGV, during its execution.


Answered By - Hisham Hijjawi
Answer Checked By - Pedro (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, November 12, 2022

[FIXED] How to save object in memory for all activity\ies when application is alive, Android

 November 12, 2022     android, caching, memcached, retrofit, rx-java     No comments   

Issue

I have an app, it uses Rxjava and Retrofit to retrieve data from backend.

after login, I will get a JSON file which includes User information (name, email, id, stripeId....). I will need to use User information when retrieving data from backend in other activities. Since there are many times I need to use the User information, saving it in Database or SharePreference may spend a lot of time.

Is there any way that I can save the data in the memory when the App is alive (not killed in the background)? Thanks first.


Solution

You can extend Application Class which is initiated on application startup. Check it here:

Extending Application to share variables globally



Answered By - Maksym V.
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, November 11, 2022

[FIXED] How to process amount for my app referrals?

 November 11, 2022     android, flutter, payment-gateway, referrals, stripe-payments     No comments   

Issue

I have developed an android app using flutter and I like to use stripe as my payment gateway.

I need to add refer and earn feature in my app. How do I need to setup this with my bank account for providing money one who refers.

I need to provide money like below example.

Example: If A refers B I need to give some referal money for A and If B refers C i need to give money for B and also some referal money for A(referral money for A nd B vary).

If this is not possible in stripe. which payment gateway provides this future ? or How to i do like this?


Solution

You need to setup your account as a platform and your users as connected account and you will be able to deduct from their accont and add to the other (receiver) user account.

Any charges goes to your account, and then you can distribute the money to users as you set it up in your platform account. That is one option, the second one is to do everything in your app admin section (calculate the amount to be paid) and create a charge according to your needs.

Read up on that in their doc https://stripe.com/docs/connect/best-practices



Answered By - Marco
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to integrate TEST PayU Payment Gateway in android application?

 November 11, 2022     android, android-webview, payment-gateway, payu     No comments   

This summary is not available. Please click here to view the post.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to set RazorPay key dynamically?

 November 11, 2022     android, gradle, payment-gateway, razorpay     No comments   

Issue

I want to set the Razorpay key dynamically.

Can anyone help me with this ?

I have tried with

implementation 'com.razorpay:checkout:1.5.13'

Checkout checkout = new Checkout();
checkout.setKeyID(MY_KEY_HERE);

Still it gives me error to set RazorPay API key in manifest.

Later i tried with custom by setting .aar in libs folder also and tried with

implementation project(name: "razorpay-android-3.8.8", ext: 'aar')

Then it gave me error while building gradle as:

ERROR: Required keys [path] are missing from map {name=razorpay-android-3.8.8, ext=aar}.


Solution

Issue resolved with this.

Steps followed:

Checkout.preload(PaymentActivity.this);
Checkout checkout = new Checkout();
checkout.setKeyID(MY_KEY_HERE);


final Activity activity = this;

checkout.open(activity, options);



Answered By - Sachin Harne
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to integrate payment online method into my Android Studio app?

 November 11, 2022     android, java, payment, payment-gateway, sandbox     No comments   

Issue

I'm a student and I have an Android Studio app for my course project. I want to integrate the debit card payment feature into my app. I have tried Paypal Sandbox but it does not work. I found Razorpay but it is only available for Indian currency.

enter image description here

I wanna build payment for USD or VNĐ. Where I can start? Please give me a tip

Thanks.


Solution

Razorpay is easy to handle online debit card payment. It supports 100 currencies including USD. https://razorpay.com/blog/best-payment-gateway-india/#:~:text=Razorpay%20is%20the%20only%20converged,UPI%2C%20and%20popular%20mobile%20wallets.e. For more information refer the former link and also this https://razorpay.com/docs/payment-gateway/android-integration/standard/



Answered By - Shruthi Holla
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, November 8, 2022

[FIXED] How to send email from broadcastreceiver?

 November 08, 2022     android, email     No comments   

Issue

I am implementing one application.

Based on my application i am created class named "RepeatingAlarm.java"

My RepeatingAlarm class extends broadcastrecevers.

I am calling the above class in every one hour.

My requirement is,when this class is called

I want to get a file from sdcard and send this file through email.

How to do this?


Solution

Add these inside onReceive method in your BroadcastReceiver.

   File file= new File(Environment.getExternalStorageDirectory()
                    + "/filefolder/"+"filename");
Uri u1  =   null;
u1  =   Uri.fromFile(file);

Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sending a file");
 sendIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] 
        {"me@gmail.com"}); 
sendIntent.putExtra(Intent.EXTRA_STREAM, u1);
sendIntent.setType("text/html");
context.startActivity(Intent.createChooser(sendIntent , "Send mail..."));


Answered By - Manikandan
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to get android:title from IMenuItem in Xamarin C#?

 November 08, 2022     android, c#, menu, xamarin     No comments   

Issue

I have added items to the toolbar menu programmatically. Now I want to access the item's title attribute. I know you can use item.getTitle() to get the title in Java, but how do would you get the title associated to that item in C#?


Solution

if you look at the docs for IMenuItem you will see that it has a TitleFormatted property that maps to the Android getTitle method.

Generally Android getPropertyName methods are mapped to C# PropertyName properties in Xamarin.



Answered By - Jason
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How can I get the options menu of my Activity?

 November 08, 2022     android, menu, optionmenu     No comments   

Issue

In some methods of my Activity I want to check the title of menu or know if it is checked or not. How can I get Activity's menu. I need something like this.getMenu()


Solution

Be wary of invalidateOptionsMenu(). It recreates the entire menu. This has a lot of overhead and will reset embedded components like the SearchView. It took me quite a while to track down why my SearchView would "randomly" close.

I ended up capturing the menu as posted by Dark and then call onPrepareOptionsMenu(Menu) as necessary. This met my requirement without an nasty side effects. Gotcha: Make sure to do a null check in case you call onPrepareOptionsMenu() before the menu is created. I did this as below:

private Menu mOptionsMenu;

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    mOptionsMenu = menu
    ...
}

private void updateOptionsMenu() {
    if (mOptionsMenu != null) {
        onPrepareOptionsMenu(mOptionsMenu);
    }
}


Answered By - Dustin
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing