Help with Android Studio App Development MAC - Android Studio

Hi everybody,
Im in need of help, Ive been attempting to create an qoute application and ive been coming up with an error when i try to run it.
Here is the error report i get.
Information:Gradle: Executing tasks: [assemble]
Information:24/03/2016, 18:33 - Compilation completed with 2 errors and 0 warnings in 8s 478ms
Error:Gradle: Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
/Users/David/AndroidStudioProjects/David'sMotivation2/app/src/main/java/com/example/david/davidsmotivation/Splash.java
Error: (16, 9) Gradle: error: reached end of file while parsing.
here is the code where it shows that there is an bug/error.
package com.example.david.davidsmotivation;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class Splash extends AppCompatActivity {
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Typeface myTypeface = Typeface.createFromAsset(getAssets(), "Papyrus.ttc");
TextView myTextview = (TextView) findViewById(R.id.textView1);
myTextview.setTypeface(myTypeface);
{
Im sorry if this isn't clear, please say if i should include more information.:good:

are u sure its is Papyrus.ttc ? usualy typefaces ends with .ttf extension
Sent from my Nexus 4 using Tapatalk

Did you post the complete Splash.java file. Because the code you posted is incomplete
Code:
package com.example.david.davidsmotivation;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class Splash extends AppCompatActivity {
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Typeface myTypeface = Typeface.createFromAsset(getAssets(), "Papyrus.ttc"); [COLOR="RoyalBlue"]// Is this correct ? Fonts are generally '.ttf' files[/COLOR]
TextView myTextview = (TextView) findViewById(R.id.textView1);
myTextview.setTypeface(myTypeface);
[COLOR="Red"][B]}
}[/B][/COLOR]

Related

[Q] return a modified copy of original method

Hey guys,
I've just started experimenting with some coding, picked up a few tutorials and made some stuff work.
Now i'm stuck at a point where i want to return a modded version of a method which will replace the original method.
This is what i have so far.
Code:
package mjxl.xposed.cm11;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class CM11notifications implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if (lpparam.packageName.equals("com.android.systemui")) {
ClassLoader classLoader = lpparam.classLoader;
XC_MethodReplacement methodreplacer = new XC_MethodReplacement() {
protected Object replaceHookedMethod(
XC_MethodHook.MethodHookParam paramAnonymousMethodHookParam)
throws Throwable {
return *WHAT DO I PUT HERE?? *;
}
};
XposedHelpers.findAndHookMethod("com.android.systemui.MmsConfig", classLoader, "applyLegacyRowBackground", methodreplacer);
}
}
}
I want to return a copy of "applyLegacyRowBackground" with some edits, so it will take my layouts.
Now i know i have to return it where "Integer.valueOf(255); is, but how to ?
Can anyone guide me ?
Here's the method which i want to place there.
Code:
protected void applyLegacyRowBackground(StatusBarNotification sbn, View content) {
if (sbn.getNotification().contentView.getLayoutId() !=
R.layout.notification_template_base_mjxl) {
int version = 0;
try {
ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(sbn.getPackageName(), 0);
version = info.targetSdkVersion;
} catch (NameNotFoundException ex) {
Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.getPackageName(), ex);
}
if (version > 0 && version < Build.VERSION_CODES.GINGERBREAD) {
content.setBackgroundResource(R.drawable.notification_row_legacy_bg_mjxl);
} else {
content.setBackgroundResource(R.drawable.notification_bg_mjxl);
}
}
}
Since the method you're replacing is void (it returns nothing): `return None;`.
PS. You're trying to hook `applyLegacyRowBackground()` instead of `applyLegacyRowBackground(StatusBarNotification, View)`. You should pass the arguments' classes to findAndHookMethod(…), for example:
Code:
XposedHelpers.findAndHookMethod("com.android.systemui.MmsConfig", classLoader, "applyLegacyRowBackground", StatusBarNotification.class, View.class, methodreplacer);
If you can't access the class directly (because it's not in the SDK, for example), pass its full class name as a string instead (e.g. "android.view.View" instead of `View.class`).

[Q] http get class android studio

Hi everyone,
I'm new in developing and i use android studio for developing my first apps that check if my device is rooted or not and collect information about device like( os version, manufacturer, model ).
My problem is that i need to integrating in my class that already created and successfully worked a http get request to display this information in http locally. ?
How can do this ?
pls note that i do not need anything more complex just a simple way to display the result in HTTP locally.
Thank you in advance
Regadrs
There is my class :
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
public class Sofiane_Byod_Service_activity_main extends ActionBarActivity {
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sofiane__byod__se rvice_activity_main);
final Button button1 = (Button) findViewById(R.id.button1);
final Button button2 = (Button) findViewById(R.id.button2);
final Button button = (Button) findViewById(R.id.button);
final TextView Text1 = (TextView) findViewById(R.id.textView5);
final TextView Text2 = (TextView) findViewById(R.id.TextView09);
final TextView Text3 = (TextView) findViewById(R.id.TextView06);
final TextView Text4 = (TextView) findViewById(R.id.TextView05);
button1.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
String command[] = {"su", "-c", "ls", "/data"};
Shell_Byod shell = new Shell_Byod();
String text = shell.sendShellCommand(command);
if ((text.indexOf("app") > -1) || (text.indexOf("anr") > -1)
|| (text.indexOf("user") > -1)
|| (text.indexOf("data") > -1)) {
button2.setText("Rooted");
} else {
button2.setText("Not Rooted");
}
String curModel = Build.MODEL;
String curMan = Build.MANUFACTURER;
String curDevice = Build.DEVICE;
String curVer = Build.VERSION.RELEASE;
Text1.setText(curDevice);
Text2.setText(curModel);
Text3.setText(curMan);
Text4.setText(curVer);
}
});
}
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I have been following a book and there is one thing I can't figure out...

I have been following a book. It seems legit but who knows... There is an activity and I'm supposed to copy whatever was in the book into the program (Android Studio) So I've finished copying the code and now there is an error, "Cannot Resolve Symbol 'menu'
I just don't get it. Here is the code. I will bold the line with the problem.
import android.app.Activity;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("lifecycle", "onCreate");
setContentView(R.layout.activity_main);
}
@override
public boolean onCreateOptionsMenu(Menu menu) {
//Inflate the menu; this adds items to the action bar
//if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@override
public void onRestart() {
super.onRestart();
Log.d("Lifecycle","onRestart");
}
@override
public void onResume() {
super.onResume();
Log.d("Lifecycle","onResume");
}
@override
public void onPause() {
super.onPause();
Log.d("Lifecycle", "onPause");
}
@override
public void onStop() {
super.onStop();
Log.d("Lifecycle", "onStop");
}
@override
public void onDestroy() {
super.onDestroy();
Log.d("Lifecycle", "onDestroy");
}
}
) of course can't resolve symbol menu, because you need to create a menu directory in the layout directory, and there create a menu_main xml file.
Trimis de pe al meu Sony Z2 D6503
How do I do that?
pascaleandrei99 said:
) of course can't resolve symbol menu, because you need to create a menu directory in the layout directory, and there create a menu_main xml file.
Trimis de pe al meu Sony Z2 D6503
Click to expand...
Click to collapse
I've made a menu directory and I have also made a menu_main.xml file. What do I do now?
yaaaaaaaa
IanJohnTom said:
I've made a menu directory and I have also made a menu_main.xml file. What do I do now?
Click to expand...
Click to collapse
i figured it out!

Gridview Display from SQLLITE DATABASE

Hi,
I would like to read data from my sqllite database. below my code but i am getting error . "Cannot resolve method maketext java.lang.exception,int)
Code:
package in.whomeninja.android_barcode_scanner;
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
public class ShowProduct extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showproduct);
GridView gvproduct=(GridView)findViewById(R.id.gvproduct);
List<String> li=new ArrayList<>();
ArrayAdapter<String> dataAdapter=new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_item,li);
dataAdapter.setDropDownViewResource(R.layout.showproduct);
try {
SQLiteDatabase db=openOrCreateDatabase("coke_db",MODE_PRIVATE,null);
Cursor cr=db.rawQuery("SELECT * FROM PRODUCT_TBL",null);
if(cr!=null){
if(cr.moveToFirst()){
do{
String no=cr.getString(cr.getColumnIndex("barcodeResult"));
String name=cr.getString(cr.getColumnIndex("latitude_textview"));
String type=cr.getString(cr.getColumnIndex("longitude_textview"));
String qty=cr.getString(cr.getColumnIndex("textView1"));
String remark=cr.getString(cr.getColumnIndex("textView6"));
//li.add(no);
li.add(no);
li.add(name);
li.add(type);
li.add(qty);
li.add(remark);
gvproduct.setAdapter(dataAdapter);
}while (cr.moveToNext());
}else{
Toast.makeText(getApplicationContext(), "No Data to show", Toast.LENGTH_LONG).show();
}
}
}catch (Exception e){
Toast.makeText(ShowProduct.this, e, Toast.LENGTH_SHORT).show();
}
}
}

move service chat head with button

hello, im having trouble moving a chathead with a button, no matter how much i try it always crashes my app
here is the main activity
im using MoveHead but i dant make it to work
Code:
package example.com.chatheads;
import android.app.Activity;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.net.sip.SipAudioCall;
import android.net.wifi.p2p.WifiP2pManager;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.app.Service;
import example.com.chatheads.ChatHeadService.*;
public class MainActivity extends Activity {
private final int xx = 500;
private final int yy = 500;
Button startService,stopService, moveService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startService=(Button)findViewById(R.id.startService);
stopService=(Button)findViewById(R.id.stopService);
moveService=(Button)findViewById(R.id.moveService);
startService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startService(new Intent(getApplication(), ChatHeadService.class));
//startService(new Intent(getApplication(), HepUstte.class));
}
});
stopService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
stopService(new Intent(getApplication(), ChatHeadService.class));
}
});
moveService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//System.out.println("Hello");
ChatHeadService inst = new ChatHeadService();
inst.UpdateEmployee();
}
});
}
and here is the chatheadservice class
Code:
package example.com.chatheads;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.os.CountDownTimer;
import android.os.IBinder;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.app.Activity;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
public class ChatHeadService extends Service {
public WindowManager windowManager;
public ImageView chatHead;
WindowManager.LayoutParams params;
int xi ;
int yi ;
@Override
public void onCreate() {
super.onCreate();
System.out.println("Hello2");
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
chatHead = new ImageView(this);
chatHead.setImageResource(R.drawable.face1);
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
params.x = 0;
params.y = 100;
chatHead.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
params.x = xi;
params.y = yi;
windowManager.updateViewLayout(chatHead, params);
}
});
windowManager.addView(chatHead, params);
}
public void MoveHead(){
System.out.println("Hello");
WindowManager.LayoutParams params = (WindowManager.LayoutParams) chatHead.getLayoutParams();
params.x = 100;
params.y = 300;
windowManager.updateViewLayout(chatHead, params);
}
@Override
public void onDestroy() {
super.onDestroy();
if (chatHead != null)
windowManager.removeView(chatHead);
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}

Categories

Resources