To test your applications which use android AudioRecord calss, you should set this class's constructor with supported device properties. In the android documentation, it says Android devices support at least;
Sample rate: 44100Mhz
Channel Type: CHANNEL_IN_MONO
Encoding: ENCODING_PCM_16BIT
But unfortunately this is not correct. Because neither emulator nor my Samsung Galaxy S2 supports this configuration. I have just discovered that the correct initialization for the android emulator is
Sample rate: 8000Mhz
Channel Type: CHANNEL_IN_MONO
Encoding: ENCODING_PCM_16BIT
this works for minimum buffer size calculation with getMinBufferSize(,,)
Cheers!
Ali Olcay Sahin, Bilgisayar, Yazılım, Internet, Software, Information Technologies
Monday, 19 December 2011
Sunday, 21 August 2011
Why do we need non-static inner class in java
Non static inner classes can reach to its enclosing class elements because they are dynamic elements of their enclosing classes. You can do that.
class A {
public void method(){}
public class B {
method(); // cannot do this if you define B as 'public static class B'
}
}
And in this case (non-static inner class). If you d like to create an instance of you inner class (B) in some other class, you should instantiate it like below.
class C {
public C(){
A.B b = new A().new B(); // B has the same characteristic like other non-static class elements
}
}
On the other hand if you aren't going to reach to the enclosing class elements from the inner class, you can define your inner class as static class. In this case you don't need to create an instance of enclosing class to create an instance of the inner class.
class C {
public C(){
A.B b = new A.B(); // this is a valid instantiation of a B's instance.
}
}
Wednesday, 3 August 2011
textview cannot be resolved to a type
There is that weird stuff in android. I have list_item.xml which is below
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:minHeight="?android:attr/listPreferredItemHeight"
></TextView>
and ArrayAdapter(view:View,textviewId:Int,items:String[]) wants a textview into 2nd parameter I was passing R.id.text1 as parameter but I needed to pass the layout (R.layout.list_item) instead of that textview. So why do you retrun 'textview cannot be resolved to a type' error to me? An example to confusing exceptions.
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:minHeight="?android:attr/listPreferredItemHeight"
></TextView>
and ArrayAdapter(view:View,textviewId:Int,items:String[]) wants a textview into 2nd parameter I was passing R.id.text1 as parameter but I needed to pass the layout (R.layout.list_item) instead of that textview. So why do you retrun 'textview cannot be resolved to a type' error to me? An example to confusing exceptions.
Saturday, 28 May 2011
Add custom repository to maven and add a library (dependency) from this repository
If you add a dependency to your project's pom.xml file, everytime when you try to build your project maven tries to connect to maven's default libraries (http://repo1.maven.com ...) and returns with a error message which says it could not find source in maven default repositories. So: lets see how can you add your custom repositories to maven and dependencies to your projects.
Scenario: there is that myLib-200.jar with a groupId which is 'aliolcicode' under the http://repo.aliolci.com
1. You have to add that custom repository to your maven settings to inform maven that 'I use my custom repositories next to maven repositories'. To do this. open your maven settings file (click here to see how) and add these lines below, between 'mirrors' tags
in XML above the important part is the url part the others are definition of your custom repository.
Scenario: there is that myLib-200.jar with a groupId which is 'aliolcicode' under the http://repo.aliolci.com
1. You have to add that custom repository to your maven settings to inform maven that 'I use my custom repositories next to maven repositories'. To do this. open your maven settings file (click here to see how) and add these lines below, between 'mirrors' tags
in XML above the important part is the url part the others are definition of your custom repository.
<mirror>
<id>aliolci</id>
<name>aliolci code repository</name>
<url>http://repo.aliolci.com</url>
<mirrorof>*</mirrorof>
</mirror>
2. Add your dependency to your project. There is nothing special about this. Just add your dependency as usual into your projects pom.xml.<dependencies>
<dependency>
<groupid>aliolcicode</groupid>
<artifactid>myLib</artifactid>
<version>200</version>
</dependency>
</dependencies>
That's it. Enjoy!
Saturday, 21 May 2011
Intellij IDEA is freezing during Maven project (pom.xml file) reimporting
There is a stupid bug for the maven projects at the intellij which is a conflict of pom.xml and and Intellij project files (.iml, .ipr, .iws). To solve this conflict, just delete these all IntelliJ project files. Then open and reimport project just over the pom.xml. IntelliJ will create all project files from the begining.
Thursday, 5 May 2011
Maven settings.xml location at Ubuntu and Windows Systems
settings.xml file is used for configuring maven builder about profiles, repositories etc. At windows systems this file can be found at;
{Maven Installed Location}\conf\settings.xml
such as: C:\Program Files (x86)\Apache Software Foundation\apache-maven-3.0.3\conf
At Ubuntu systems it can be found under
/etc/maven2/settings.xml
{Maven Installed Location}\conf\settings.xml
such as: C:\Program Files (x86)\Apache Software Foundation\apache-maven-3.0.3\conf
At Ubuntu systems it can be found under
/etc/maven2/settings.xml
Sunday, 1 May 2011
Ubuntu 11.04 set a new environment variable (persistently)
Custom environment variables are stored in /etc/environment file.
sudo gedit /etc/environment
If you open this file you will see the PATH variable's value. If you would like to set a new one just move to new line and set your variable in {variable_name}="{variable_value}" format. Such as JAVA_HOME="/usr/lib/jvm/java-6-sun/bin"
DONT FORGET TO OPEN FILE AS SUPER USER and restart your computer after you saved the changes.
To see the list of environment variables:
bash$ export
sudo gedit /etc/environment
If you open this file you will see the PATH variable's value. If you would like to set a new one just move to new line and set your variable in {variable_name}="{variable_value}" format. Such as JAVA_HOME="/usr/lib/jvm/java-6-sun/bin"
DONT FORGET TO OPEN FILE AS SUPER USER and restart your computer after you saved the changes.
To see the list of environment variables:
bash$ export
Etiketler:
environment variable,
linux,
ubuntu
Subscribe to:
Posts (Atom)