How to Check if the number is Triangular or Square in Android

How to Check if the number is Triangular or Square in Android

Another Headache! You are stuck in Android App where you can to check if number is triangular or check if number is square but you’ve not good luck yet.

Let’s start the Android Studio, create a new empty activity, open up the XML of the activity and paste the following code.

 

Now Open the java file for that activity and paste the following code.

Replace isSquareTriangular class name with your class name, also edit the package for the class.

An output like this will be created, where you can easily put a number which the program will check if number is triangular, check if number is square or both.

[[Also check If you’re stuck at Activity must be exported or contain a Intent-Filter]]

In the below example, you can see that the Toast message shows that the number (1) is Both. If you will check other numbers it will tell you the other two parts of App if number is triangular or square.

if number is triangular

 

Final Words on Check If Number is Triangular or Square

Sometimes the university or college assignment and mini projects will ruin your happiness but not anymore, Just follow the above steps, if there anything wrong or you have a question just ask us in the comment section.

How to Run a Specific Activity in Android Studio?

How to Run a Specific Activity in Android Studio?

As title mentioned that you want to run a specific activity in Android Studio

We got a possible solution for you.

Possible Solution

Your Android Manifest will contain all the activities code, all you need is to add

This one line into your activity tag. This will allow the IDE to run a specific activity in Android Studio.

Now go the Run from the Menu or press ALT+U to open the Run drop-down menu. Choose Edit Configuration from the list.

run a specific activity in android studio

Now from the Launch Option Select the Specified Activity and start typing in the activity text input, the android studio will automatically show you the list of all activities, select one from them or write the name of your activity.

running specific activity in android studio

Hit the Apply and Ok button, and Run your App.

Final Words on Run a Specific Activity in Android Studio

So, this is how we do running of specific activity in android, if you face any problem just let us know in the comment section.

Create Android Transparent Activity in 3 Possible Ways

Create Android Transparent Activity in 3 Possible Ways

Sometimes we need to have android transparent activity and transparent screen in our Application, which is totally possible by playing around with the android activity and resource file a little bit. You can create transparent activity on android by applying the possible three ways to accomplish your goal.

Possible Solution 1

Look for the style.xml file in the resource folder, or simply go to res/values/styles.xml, open it and add the following code to it.

The value of @color/transparent is #000000, which you can add to your project. (if you’re not familiar to it then follow the below)

Now create another file in the resource folder and name it as “colors.xml” and paste the following code in it.

You can add more colors to it according to your needs.

In your activity file, you can now add the following transparent background to your activity tag.

If Your App is Crashing then it is derived from AppCompatActivity, so remove parent=”android:Theme” from the parent tag and it will start working.

[Android Error] Facing error in the intent filter? get your solution now. 

Possible Solution 2

Adding this code to your activity tag in manifest file will make android transparent activity. Assign Translucent Theme to the activity and it will work fine.

Possible Solution 3

This is also a possible way to create android transparent activity, just add that one line to your onCreate function, just below the setContentView which will make the background completely transparent.

For the dialogs, you can use this code to make an Android transparent activity

Final Words on Android Transparent Activity

These three possible solutions or ways can help you to create transparent activities on android. If none of them works for you just let us know in the comment section, we will try our best to get back to you as soon as possible. Please provide us with all the details, what you’ve already applied and little snap your code would be highly appreciated.

Android Error: The Activity Must be Exported or Contain an Intent-Filter

Android Error: The Activity Must be Exported or Contain an Intent-Filter

When you run the android application in the Android Studio and you face an error, The Activity Must be Exported or something like below.

Error running Dashboard: The activity must be exported or contain an intent-filter

There are possible solutions which can help in getting rid of the error.

Possible Solution 1

if you face The Activity Must be Exported error. First, you should double check the manifest code and look for below code.

Your main activity must have this code inside the activity tag. It should look like

Possible Solution 2

if The Activity Must be Exported error doesn’t go away by following the solution 1 then follow solution 2.

There is a drop-down menu beside the Green Run (play) icon. Select the “app” from the drop-down and run your app again.

The Activity Must be Exported - Android Studio

 

Coding in the android studio is not so hard but sometimes we face errors which really make us annoy but we try our best to get rid of the errors, sometimes it’s hard to find the solution to the problem or error.

Final Words for The Activity Must be Exported Error

If the problem still persists, and you’re not able to solve it, just let us know in the comment with the snap of code and little description that what you’re trying to do. We will try our best to get back to you as soon as possible.