Показаны сообщения с ярлыком java. Показать все сообщения
Показаны сообщения с ярлыком java. Показать все сообщения

вторник, 17 декабря 2019 г.

[Android] admob invalid application id fix

If you tried everything from https://developers.google.com/admob/android/quick-start#update_your_androidmanifestxml and still doesn't work, get a test Ads from here , for example Banner ad format, paste it into your AndroidManifest.xml and change its meta-data value slash symbol (/) to tilda (~).

пятница, 29 ноября 2019 г.

[Android] you must set design_width and design_height in your manifest file - how to fix

It looks like you use com.zhy.autolayout library, you can workaround it with using original AppCompatActivity instead of AutoLayoutActivity like this:

...
import androidx.appcompat.app.AppCompatActivity;

public abstract class BaseCameraActivity extends AppCompatActivity {
...

Works on Android API 28

четверг, 12 января 2017 г.

Intellij Idea - "gradle project sync failed" in Android project

Press "Refresh all Gradle projects" in View > Tool Windows > Gradle

воскресенье, 10 января 2016 г.

Cannot add background to Android designer Intellij IDEA

Add file to "%project%/res/drawable-hdpi" and select it via background selection dialog.

configure Intellij IDEA for Android project

1. do not forget to install Android SDK;
2. just add "Android support" in Plugins in Idea. It because you installed IDE without Android plugin.

четверг, 26 ноября 2015 г.

My working minimal pom.xml


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.projectgroup</groupId> <artifactId>projectname</artifactId> <version>01.03.03-00</version> <build> </build></project>
(c) http://habrahabr.ru/post/126966/ 

понедельник, 14 сентября 2015 г.

Finding palindrome in array in Java

static ArrayList<String> arr = new ArrayList<>();
public static void palidrome() throws IOException {
InputStream fis = new FileInputStream("C://tmp/palidrome.txt");
InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8"));
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) arr.add(line);
for (int i=0; i<arr.size(); i++) {
if (!isPal(arr.get(i))) arr.set(i, "-1");
System.out.println(arr.get(i));
}
}
public static boolean isPal(String str) {
int i=0; int k = str.length()-1;
while (i<=k) {
if (str.charAt(i)==str.charAt(k) ) {
i++;
k--;
}
else return false;
}
return true;
}

воскресенье, 6 сентября 2015 г.

Quicksort in Java example

quicksort is the fastest sorting algorithm, and here is example of method in Java:
static public void quickSort(int[] arr, int l, int r) {
        int left = l; int right = r; int tmp;
        int middle = arr[(left + right) / 2];
       
        while (left <= right) {
            while (arr[left]<middle) left++;
            while (arr[right]>middle) right--;
            if (arr[left]>arr[right]) {
                tmp = arr[left];
                arr[left] = arr[right];
                arr[right] = tmp;
            }
        }
        if (left<r) quickSort(arr, left, r);
        if (l<right) quickSort(arr, l, right);
       
    }
It needs to be called like this:
public static void main(String args[]) {
int[] array = { 4, 23,65, 76, 99, 12, 90, 34 }
quickSort(array, 0, array.length-1)
}

вторник, 25 августа 2015 г.

JAVA convert string[] to binary array

piece of code:
byte[] byt = MESSAGE.getBytes();
String bin = "";
for (int i : byt) bin += Integer.toBinaryString(i);
System.err.println(bin);

среда, 29 июля 2015 г.

Helloworld in Java Graphics2D

For this need to make 2 classes with names Painting and Frame. In my situation I have package named graphh
Painting.class:
package graphh;
import java.awt.*;
import javax.swing.*;
public class Painting extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawOval(60, 80, 20, 20);
}
}

Frame.class:
package graphh;
import java.awt.*;
import javax.swing.*;
public class Frame {
public Frame() {
JFrame gui = new JFrame();
gui.setTitle("fsdfdsf");
gui.setSize(400, 300);
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Painting panel = new Painting();
Container pane = gui.getContentPane();
pane.setLayout(new GridLayout(1, 1));
pane.add(panel);
gui.setVisible(true);
}
public static void main(String args[]) {
new Frame();
}
}

If you are using Eclipse just press Run button
Taken from https://www.youtube.com/watch?v=U2G_2AS0otE