How can I remove the Android application label? - java

I made my first app today on my phone using an application named "A.I.D.E".
How can I remove my app name and label from the top of the main screen? I named my app "YT Studio", but I don’t want to show this name and label on top of my main screen. I want it to be blank. How can I do it?
I provided the android manifest.xml and main.java file for the reference.
File android manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ojhastudios.ytstudio" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="YT Studio"
android:theme="#style/AppTheme"
android:resizeableActivity = "true">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
File main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="#string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" />
</LinearLayout>
The code:
package com.mycompany.myapp;
import android.app.*;
import android.os.*;
public class MainActivity extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getSupportActionBar().hide();
}
}

You can just call
getSupportActionBar().hide();
in your activity's onCreate() method.
The method given above does not work when using an Android 10 activity. It works with AppCompatActivity.
So, this answer will do the task.
In your AndroidManifest.xml, find your activity and then you should add this line in it:
<application>
...
<activity
android:name=".MainActivity"
android:theme="#style/Theme.MaterialComponents.Light.NoActionBar">
...
</activity>
...
</application>

Go to src/main/res/values and open file theme.xml:
Then change your style name to NoActionBar. It removes your action bar:

Go to res → values → themes
<style name="Theme.MyAppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
...
...
</style>
Change it to Theme.MaterialComponents.Light.NoActionBar. The magic here is the NoActionBar and your toolbar will be removed completely, including the app title name. But you should know this, after you change it, it’s going to be removed from your entire project, not just the single activity.

Related

how can I assign a widget's settings when I put it on the home screen

How can I open an Activity at the start of a widget to set the required settings?
The idea is to on putting a widget on the main screen to be able to define which i.e. the working database through an index.
To start some activity right after put widget on screen, it's enough to define in the manifest with this intent-filter:
<activity android:name=".ConfigurationActivity">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>
</activity>
then add android:configure entry in AppWidgetProviderInfo metadata:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure=".ConfigurationActivity"
android:initialLayout="#layout/widget_layout"
android:minHeight="50dp"
android:minWidth="50dp"
android:updatePeriodMillis="50000" />

Imposible to develop a simple android app using Google Map API V2

I would like to use a Google Map in my current application. Before integrate it to my app, I created a test project to understand the functionalities.
I read this : https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
and this :
http://developer.android.com/google/play-services/setup.html#
After a lot of problems with these errors :
didn't find class com.google.android.gms.maps.MapFragment
and
Found 2 versions of android-support-v4.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time)
When I run my project, Eclipse says "Launching Test:(99%)", then my computer temperature up to 100°C and Eclipse take 512% of my CPU ! So I'm obliged to force Eclipse to quit.
I spent a lot of time on stack overflow, rebuild, clean, add support library, delete project and recreate from the beginning etc.
Help me, I just want to create a basic app to test a GoogleMap !
My code :
MainActivity.java
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="***" />
</application>
</manifest>
Edit : I know now that the problem appears when I reference the google-play-services_lib to my project... Any ideas ?
public class YourActivity extends FragmentActivity {
GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity);
map =((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.iqamah_map)).getMap();
}
}
your xml :
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/iqamah_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment" />
Add this in your Manifest
<uses-permission android:name="com.example.test.permission.MAPS_RECEIVE" />
<uses-library android:name="com.google.android.maps" />
Even me having the same issue, then instead of getting API key from Google Map Android V2, i took the API key from Google Maps Embed API and included in the Manifest and solved my problem.
Proof:
1.API key i took for project
2.Used Key in Manifest.xml

Android file crashes on emulator and on physical device while requesting URL from Google Images

I know many of you will say "check your settings when creating the project," but I did. I checked and my physical device (Samsung S3) uses Android 4.3 and I set the minimum requirement to 2.2 and target to 4.3. I think it might be my code because I've been able to run other Android applications using the eclipse ADT emulator I just never tried it on an actual device and it just doesn't even show up in my emulator.
Here is my java code:
package com.example.bitmapdisplay;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
URL req = new URL("http://i1.cpcache.com/product_zoom/617914535/dickbutt_2_mug.jpg? side=Back&height=250&width=250&padToSquare=true");
ImageView image = (ImageView) findViewById(R.id.ivImage);
Bitmap mIcon_val= BitmapFactory.decodeStream(req.openConnection()
.getInputStream());
image.setImageBitmap(mIcon_val);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Here is my XML layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}" >
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
Here is my XML Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bitmapdisplay"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name="com.example.bitmapdisplay.MainActivity"
android:label="#string/app_name" >
<intent-filter> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Need to look at the logCat for more info but one problem that i can see in your manifest is that you have intent-filters missing. Inside your application
android.intent.category.MAIN is given to the activity wich is going to launch at first.
Try this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Add these two lines to your activity tab and this will tell android this is the main starting activity.
whether the message appears in the console messages like this example? :
uploading your.apk onto device '0123456789ABCDEF'
installing your.apk
starting activity

Beginner Android App Crashes

I'm doing a beginner android primer book and the code seems simple enough. However, it cannot run. When I try to run it, eclipse crashes.
Here's my java code:
package com.example.gamebeginner;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity implements View.OnClickListener {
Button button;
int touchCount;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
button = new Button(this);
button.setText("Touch me!");
button.setOnClickListener(this);
setContentView(button);
}
public void onClick(View v){
touchCount++;
button.setText("Touched me " + touchCount + " times(s)");
}
}
activity.main xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world" />
</RelativeLayout>
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gamebeginner"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:debuggable="true" >
<activity
android:name="com.example.gamebeginner.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I'm on jdk version 1.6. any help would be much appreciated.
Make sure you device is connected and working correctly.
Go to window -> show view -> android -> devices click ok so that you
open the device list. Make sure you see your device listed in the
window.
Make sure that you click on the device so the device is highlighted.
Now go and click on your logcat tab. If you do not have the logcat
tab opened, go to window -> show view -> other -> android -> logcat.
Make sure you DO NOT select the deprecated version.
Also try killing and restarting the adb daemon.
adb kill-server and then adb start-server at a command prompt. If you do not have adb on your path, you will need to reference the full path to adb or do the command within the directory that contains adb.
Disconnecting and reconnecting the device solved the issue.
If your error message (in logcat, right?) is java se binary is not responding, I would venture to say that you are generating the code in the wrong way somehow. Are you using Eclipse or IntelliJ to build your app? What is the project type you are using - Java application, or Android application?
First add setContentView and afer View

something wrong with my webview of android

I am using: windows7, eclipse, sdk up-to-date, avd from android 2.3.3 & milestone <-the NVPACK - in fact
the problem is discussed everywhere, but the solutions did not work for me.
When I try to load a url, it turns out a blank white page
some was saying about htmls, but no ,mine is http://www.google.com or http://www.baidu.com or file:///android_asset/demo.html etc.
and the most carried out solutions
the permission:
<uses-permission android:name="android.permission.INTERNET" />
the javscript switcher
mWebView.getSettings().setJavaScriptEnabled(true);
and then my all code:
the java
package xiamubobby.inoroy.androidtest;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
public class WebViewDemo extends Activity {
private WebView mWebView;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
}
}
the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xiamubobby.inoroy.androidtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".AndroidtestActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
the main.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Can anybody tell me what I did wrong? I am hoping for rescue.
Since I'm not a very experienced programmer, maybe there be very silly mistakes. Thank you for your patience.
if WebViewDemo is your start activity then you have to change your AndroidManifest.xml: replace android:name=".AndroidtestActivity" with android:name=".WebViewDemo"

Categories

Resources